You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
651 B

using System;
using System.Drawing;
using System.IO;
namespace EC.Utils.ImageHelpers
{
public partial class ImageHelper
{
public static byte[] ImageToByteArray(System.Drawing.Image imageIn)
{
try
{
if (imageIn == null)
{
return null;
}
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
return ms.ToArray();
}
catch (Exception ex)
{
return null;
}
}
public static Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
}
}