C# Image , Byte , URL To Image Convert
public class ImageHelper
{
public byte[] ImageToByte(Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
return ms.ToArray();
}
public Image ByteToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
public Image GenerateThumbnailImage(string imgUrl)
{
Image imgThumb = null;
try
{
Image image = null;
if (imgUrl != String.Empty)
image = Image.FromFile(imgUrl);
if (image != null)
{
imgThumb = image.GetThumbnailImage(130, 170, null, new IntPtr());
//this.Refresh();
}
return imgThumb;
}
catch
{
return imgThumb;
}
}
}