How to: Convert a BMP image to a PNG image

.NET Framework (current version)

Oftentimes, you will want to convert from one image file format to another. You can do this conversion easily by calling the Save method of the Image class and specifying the ImageFormat for the desired image file format.

The following example loads a BMP image from a type, and saves the image in the PNG format.

        private void SaveBmpAsPNG()
            Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");
            bmp1.Save(@"c:\button.png", ImageFormat.Png);

This example requires:

  • A Windows Forms application.

  • A reference to the System.Drawing.Imaging namespace.

How to: List Installed Encoders
Using Image Encoders and Decoders in Managed GDI+
Types of Bitmaps