Page 1 of 1

[SOLVED] How to load image from MemoryStream?

Posted: Tue May 17, 2016 12:31 pm
by bmcguire
Hello.

Is there a work around for loading a BitmapImage from a MemoryStream, given that SetSource does not seem to be supported yet?

Thanks,

Bruce.

Re: How to load image from MemoryStream?

Posted: Sat Mar 04, 2017 8:05 pm
by JS-Support @Userware
Hi,

We are pleased to inform you that the SetSource feature, to load an image from MemoryStream, has been implemented in Beta 10.10 and newer.

Here is an example showing a WCF SOAP web service that returns an image as a byte array:

Code: Select all

void proxy_GetImageCompleted(object sender, GetImageCompletedEventArgs e)
{
    byte[] byteArray = e.Result.Image;
    using (MemoryStream stream = new MemoryStream(byteArray, 0, byteArray.Length))
    {
        BitmapImage b = new BitmapImage();
        b.SetSource(stream);
        imageControl.Source = b;
    }
}


Please note that, in case of large images, it is recommended to load the image from a URL instead of a byte array/stream instead, to ensure the best memory consumption and performance.


You can download the latest version of the product from:
http://forums.cshtml5.com/viewforum.php?f=6

Thanks.
Regards,
JS-Support