Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

How to convert BMP to GIF in C#

By , 2 Dec 2010
Rate this:
Please Sign up or sign in to vote.
Very nice work. I would add a bit of reformatting and place it in all in method:
public static void BitmapToGIF(string BitmapFile, string GIFFile)
    using (Bitmap bitMap = new Bitmap(BitmapFile))
            //var codecInfo = GetEncoderInfo(ImageFormat.Gif);
            var codecInfo = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Gif.Guid);
            using (var paramsEncoder = new EncoderParameters(2))
                paramsEncoder.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionLZW);
                paramsEncoder.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 0L);
                bitMap.Save(GIFFile, codecInfo, paramsEncoder);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Kevin Marois
President Marois Consulting
United States United States
No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 2 Dec 2010
Article Copyright 2010 by Kevin Marois
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid