bitmapとbyte[]間の相互変換
1445 ワード
C#BitmapタイプとByte[]タイプの相互変換
Bitmap => byte[]
Bitmap b = new Bitmap( "test.bmp ");
MemoryStream ms = new MemoryStream();
b.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes= ms.GetBuffer(); //byte[] bytes= ms.ToArray(); , ,
ms.Close();
byte[] => Bitmap
byte[] bytelist=bytes;
MemoryStream ms1 = new MemoryStream(bytelist);
Bitmap bm = (Bitmap)Image.FromStream(ms1);
ms1.Close();