public Image ReadImage(byte[] bytes)
{
     MemoryStream ms=new MemoryStream(bytes,0,bytes.Length);
     BinaryFormatter bf = new BinaryFormatter();
     object obj=bf.Deserialize(ms);   
  ms.Close(); 
  return (Image)obj;
}
/// <summary>
/// 将Image转换为byte[]
/// </summary>
/// <param name="image">Image</param>
/// <returns>byte[]</returns>

public byte[] ConvertImage(Image image)
{
     MemoryStream ms=new MemoryStream();
     BinaryFormatter bf = new BinaryFormatter();
     bf.Serialize(ms,(object)image);
     ms.Close();
     return ms.ToArray();
}

posted on 2013-10-06 09:13  万德源  阅读(387)  评论(0编辑  收藏  举报