boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

C# – Convert bitmap into byte array

Updated on     Kisan Patel

Problem

c# – Convert a bitmap into a byte array
c# – Convert Bitmap to byte
C# convert a BitMap to Byte[] Bitmap to byte array in C# – .NET

Solution

There are a couple ways.

Using ImageConverter Class

public static byte[] ImageToByte(Image img)
{
    ImageConverter converter = new ImageConverter();
    return (byte[])converter.ConvertTo(img, typeof(byte[]));
}

This one is convenient because it doesn’t require a lot of code.

Using MemoryStream Class

public static byte[] ImageToByte2(Image img)
{
    byte[] byteArray = new byte[0];
    using (MemoryStream stream = new MemoryStream())
    {
         img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
         stream.Close();

         byteArray = stream.ToArray();
    }
    return byteArray;
}

C#

Leave a Reply