User-1136466523 posted
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
From your description, it seems that you want to convert the bytes[] to image, right?
<o:p> </o:p>
If so, you may try the following code snippet:
<o:p> </o:p>
public 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;
}
<o:p> </o:p>
public static Image ConvertByteArrayToImage(byte[] byteArray)
{
if (byteArray != null)
{
MemoryStream ms = new MemoryStream(byteArray, 0,
byteArray.Length);
ms.Write(byteArray, 0, byteArray.Length);
return Image.FromStream(ms, true);
}
return null;
}
<o:p> </o:p>
Thanks.