Convert Bitmap to byte array - CSharp System.Drawing

CSharp examples for System.Drawing:Image Convert

Description

Convert Bitmap to byte array

Demo Code


using System.Drawing;

public class Main{
        /// <summary>
        /// Converte um Bitmap em byte array
        /// </summary>
        /// <param name="instance">Bitmap a ser convertido</param>
        /// <returns>byte array convertido</returns>
        public static byte[] ToByteArray(this Bitmap instance)
        {/*from   w w w. ja va2  s  . com*/
            ImageConverter converter = new ImageConverter();
            return (byte[])converter.ConvertTo(instance, typeof(byte[]));
        }
}

Related Tutorials