/// <summary>
/// 將byte[]轉換為Image
/// </summary>
/// <param name="bytes">字節數組</param>
/// <returns>Image</returns>
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();
}