[SOLVED] Convert picture bytearray to image source

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
hamej
Posts: 37
Joined: Thu Oct 01, 2015 8:41 am

[SOLVED] Convert picture bytearray to image source

Postby hamej » Thu Oct 15, 2015 5:19 am

When i receive a picture serialized to a byte array, I used to do this to convert it to an image source:

BitmapImage bmi= new BitmapImage();
MemoryStream ms = new MemoryStream(PictureBytes);
bmi.SetSource(ms);
Image.Source = bmi;

Problem: SetSource is currently not supported for the Image class.

Until it will be supported: anybody have a work around?

hamej

rampatter
Posts: 1
Joined: Mon Nov 30, 2015 12:12 am

Re: Convert picture bytearray to iameg source

Postby rampatter » Mon Nov 30, 2015 12:14 am

Try this

using (MemoryStream mStream = new MemoryStream(byteArrayIn))
{
return Image.FromStream(mStream);
}

Full Source : ByteArray to Image

Patter

hamej
Posts: 37
Joined: Thu Oct 01, 2015 8:41 am

Re: Convert picture bytearray to image source

Postby hamej » Fri Mar 11, 2016 2:38 am

New problem: FromStream not supported for Image.

bmcguire
Posts: 4
Joined: Wed May 11, 2016 10:23 am

Re: Convert picture bytearray to iameg source

Postby bmcguire » Tue May 17, 2016 10:31 am

Hello.

Did you ever get a solution to this problem?

Thanks,

Bruce.

hamej
Posts: 37
Joined: Thu Oct 01, 2015 8:41 am

Re: Convert picture bytearray to iameg source

Postby hamej » Tue May 17, 2016 11:13 pm

So far no. But the c#/XAML folks have promises, that it will be solved in a beta later this year. For now I have used a work around by setting the image.source = direct path to the image file on the server like this:

http://localhost:62470/App_Data/Billeder/xxx.jpg

JS-Support
Site Admin
Posts: 664
Joined: Tue Apr 08, 2014 3:42 pm

Re: Convert picture bytearray to iameg source

Postby JS-Support » Sat Mar 04, 2017 7:57 pm

Hi,

We are pleased to inform you that this feature has been implemented in Beta 10.10 and newer.

You can download it from:
http://forums.cshtml5.com/viewforum.php?f=6

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.

Thanks.
Regards,
JS-Support


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 2 guests

 

 

cron