/// <summary>
/// Convert byte array to picture
/// </ summary>
/// <param name = "buffer"> byte array </ param>
/// <returns> picture </ returns >
public Image BytesToImage (Byte [] buffer)
{
var ms = new MemoryStream (buffer, 0, buffer.Length);
var bf = new BinaryFormatter ();
object obj = bf.Deserialize (ms);
ms.Close ();
return (Image) obj;
}
/// <summary>
/// Convert image to byte array
/// </ summary>
/// <param name = "image"> Image </ param>
/// <returns > Byte array </ returns>
public byte[] ImageToBytes(Image image)
{
var ms = new MemoryStream();
var bf = new BinaryFormatter();
bf.Serialize(ms, image);
ms.Close();
return ms.ToArray();
}
Take notes