Share via


How to: Convert a BMP image to a PNG image

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.

Example

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

Private Sub SaveBmpAsPNG()
    Dim bmp1 As New Bitmap(GetType(Button), "Button.bmp")
    bmp1.Save("c:\button.png", ImageFormat.Png)

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

Compiling the Code

This example requires:

  • A Windows Forms application.

See Also

Tasks

How to: List Installed Encoders

Concepts

Types of Bitmaps

Other Resources

Using Image Encoders and Decoders in Managed GDI+