WPF: Convert memory stream to BitmapImage?

Posted by David Veeneman on Stack Overflow See other posts from Stack Overflow or by David Veeneman
Published on 2011-03-18T00:02:59Z Indexed on 2011/03/18 0:09 UTC
Read the original article Hit count: 229

Filed under:

I have an image that was originally a PNG that I have converted to a byte[] and saved in a database. Originally, I simply read the PNG into a memory stream and converted the stream into a byte[]. Now I want to read the byte[] back and convert it to a BitmapImage, so that I can bind a WPF Image control to it.

I am seeing a lot of contradictory and confusing code online to accomplish the task of converting a byte[] to a BitmapImage. I am not sure whether I need to add any code due to the fact that the image was originally a PNG.

Can anyone provide the code to convert the stream to a BitmapImage? Thanks for your help.

© Stack Overflow or respective owner

Related posts about wpf