I have a byte[] that represents the raw data of an image. I would like to convert it to a BitmapImage.
byte[]
BitmapImage
I tried several examples I found but
public static BitmapImage LoadFromBytes(byte[] bytes) { using (var stream = new MemoryStream(bytes)) { stream.Seek(0, SeekOrigin.Begin); var image = new BitmapImage(); image.BeginInit(); image.StreamSource = stream; image.EndInit(); return image; } }