image1.Source = new BitmapImage(new Uri(@"C:\IMAGE.JPG"));Additional Reading at :
Thursday, April 10, 2014
C# WPF Load Image from file
How to load image WPF:
C# Load Image to PictureBox
How to load image to picturebox:
Method 1 :
Method 1 :
PictureBox1.Image = Image.FromFile(@"C:\IMAGE.JPG");Method 2 :
PictureBox1.Image = New Bitmap(@"C:\IMAGE.JPG");Additional Reading at :
C# Convert Image to byte array (byte[]) or C# convert byte array (byte[]) to Image
Convert Image to byte[] method:
public byte[] imageToByteArray(Image imageIn) { using (var ms = new System.IO.MemoryStream()) { System.Drawing.Imaging.ImageFormat format; switch (imageIn.MimeType()) { case "image/png": format = ImageFormat.Png; break; case "image/gif": format = ImageFormat.Gif; break; default: format = ImageFormat.Jpeg; break; } imageIn.Save(ms, format); return ms.ToArray(); } }Convert byte[] to Image method:
public Image byteArrayToImage(byte[] byteArrayIn) { using (var ms = new System.IO.MemoryStream(byteArrayIn)) { Image returnImage = Image.FromStream(ms); return returnImage; } }Additional Reading at :
Labels:
byte array,
byte[],
C#,
Conversion,
convert,
CSharp,
Image,
ImageFormat,
MemoryStream
Subscribe to:
Posts (Atom)