How to Convert Image to Byte Array or Bitmap
This time I present code that can help you work with images (System.Drawing).
I showed how to convert Image to Byte Array and how to convert Image to Bitmap.
here is the code:
Yours,
Roi
I showed how to convert Image to Byte Array and how to convert Image to Bitmap.
here is the code:
/// <summary>
/// Image Converter from Image to byte array
/// </summary>
/// <param name="img">Image</param>
/// <returns>byte</returns>
public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
/// <summary>
/// Image Converter from Image to Bitmap
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
public static Bitmap ImageToBitmap(Image img)
{
ImageConverter converter = new ImageConverter();
return (Bitmap)converter.ConvertTo(img, typeof(Bitmap));
}
/// Image Converter from Image to byte array
/// </summary>
/// <param name="img">Image</param>
/// <returns>byte</returns>
public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
/// <summary>
/// Image Converter from Image to Bitmap
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
public static Bitmap ImageToBitmap(Image img)
{
ImageConverter converter = new ImageConverter();
return (Bitmap)converter.ConvertTo(img, typeof(Bitmap));
}
Yours,
Roi
Comments
Post a Comment