Have a Snippet?

Keep, track and share your code snippets with your friends

C#: Image to byte array Share on Vkontakte

Image to byte array

public static byte[] imageToByteArray(Image imageIn)
        {
            MemoryStream ms = new MemoryStream();
            imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            return ms.ToArray();
        }


Tag: Bytes, image, C#

4 Comments

  1. Avatar
    seaman

    30th May 2013, 08:07

    А поток закрывать не надо?

  2. Avatar
    RedOctober

    31st May 2013, 13:49

    Testing BB-codes: bold text, italic text, some code here

    echo ('My Cool String');

  3. Avatar
    stalin

    3rd June 2013, 08:54

    AndrewSt, верно, я не позаботился о ресурсах вовремя.