image与byte数组的转换

// image to byte[]

   Image photo
= new Bitmap(selectPictureFile);
   System.IO.MemoryStream ms
= new System.IO.MemoryStream();
   photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  
byte [] imagedata = ms.GetBuffer();

 

 // byte[] to image
   System.IO.MemoryStream ms = New IO.MemoryStream(imagedata)
   Bitmap b
= new Bitmap(ms);
   //img = Drawing.Image.FromStream(ms)

你可能感兴趣的:(image与byte数组的转换)