Image和byte[]之间的转换

image到byte[] 用到memoryStream类 

public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
 MemoryStream ms = new MemoryStream();
 imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
 return  ms.ToArray();
}
 


 

byte[] 到Image同样要MemoryStream类(http://www.my400800.cn )

主要方法:

 

MemoryStream stream = new MemoryStream(byte[] bytes);

    Image image = Image.FromStream(stream);
 

你可能感兴趣的:(byte[])