C# Image和Byte[]互相转换

转换方法:

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

 

posted @ 2013-10-25 16:51  Moulton  阅读(260)  评论(0编辑  收藏  举报