Skip to content

Instantly share code, notes, and snippets.

@LGM-AdrianHum
Created January 14, 2016 22:51
Show Gist options
  • Save LGM-AdrianHum/a5dded75df492b112c53 to your computer and use it in GitHub Desktop.
Save LGM-AdrianHum/a5dded75df492b112c53 to your computer and use it in GitHub Desktop.
public void LoadBitmapFromStream()
{
System.Drawing.Image bmp = System.Drawing.Bitmap.FromFile(@"C:\Temp\test.png");
MemoryStream strm = new MemoryStream();
bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Bmp);
strm.Position = 0;
System.Drawing.Image img = System.Drawing.Image.FromStream(strm);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
bi.EndInit();
imgBox.Source = bi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment