How to convert from type Image to type BitmapImage?
Bitmap img = (Bitmap) Image.FromStream(memStream);
BitmapImage bmImg = new BitmapImage();
using (MemoryStream memStream2 = new MemoryStream())
{
img.Save(memStream2, System.Drawing.Imaging.ImageFormat.Png);
memStream2.Position = 0;
bmImg.BeginInit();
bmImg.CacheOption = BitmapCacheOption.OnLoad;
bmImg.UriSource = null;
bmImg.StreamSource = memStream2;
bmImg.EndInit();
}
From this post
public BitmapImage ImageFromBuffer(Byte[] bytes)
{
MemoryStream stream = new MemoryStream(bytes);
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
return image;
}