Created
January 14, 2016 22:51
-
-
Save LGM-AdrianHum/a5dded75df492b112c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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