look :
private static byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert,
ImageFormat formatOfImage)
{
byte[] Ret;
try
{
using (MemoryStream ms = new MemoryStream())
{
imageToConvert.Save(ms,formatOfImage);
Ret = ms.ToArray();
}
}
catch (Exception) { throw;}
return Ret;
}
When you are ready to convert the byte array back
to an image, you can include the following code
in your method.
System.Drawing.Image newImage;
using (MemoryStream ms = new MemoryStream(myByteArray,0,myByteArray.Length))
{
ms.Write(myByteArray,0,myByteArray.Length);
newImage = Image.FromStream(ms,true);
}