[C#] - image与byte数组的转换

来源:http://hi.baidu.com/donghaozheng/blog/item/91bf0c08fd60f4d463d9863b.html

 

// 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)
posted @ 2010-03-24 11:07  炎峰森林影  阅读(698)  评论(0编辑  收藏  举报