Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Create a System.Windows.Media.ImageSource From a Byte Array?

How do I create a System.Windows.Media.ImageSource from a byte array?

I have a byte array, containing the exact and complete file contents of a TIFF image file. I need to display this on the screen, and I have no idea where to even start.

Supposedly, it can be done (according to my boss, our dev team has done it in the past, but nobody remembers how).

Has anyone here ever done something like this before?

like image 462
Giffyguy Avatar asked Aug 03 '26 14:08

Giffyguy


1 Answers

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = new MemoryStream(ByteArray);
bi.EndInit();

Also see Load a WPF BitmapImage from a System.Drawing.Bitmap and Using Image control in WPF to display System.Drawing.Bitmap

like image 53
Lars Truijens Avatar answered Aug 06 '26 04:08

Lars Truijens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!