Convert image format from .bmp to other image formats in vb.net

image-manipulation, vb.net

Solution

The system.Drawing.Bitmap class can handle opening and saving any kind of bitmap image, including JPG, PNG, GIF, BMP, and others.

To save an already opened file as a different format you can use the save method as so

MyImage.Save("ImageName.jpg",System.Drawing.Imaging.ImageFormat.Jpeg)

The class name of Bitmp refers more specifically to the general concept of storing a picture as a series of coloured pixels rather then the actual format of BMP, which is one possible way to store the representation of the pixels that make up an image.

Problem

How do you convert a `System.Drawing.Bitmap` image to another type of image? I tried CType, which failed, since I do not know the type for .png or .jpg. I cannot find it anywhere on google either. What is the most efficient method to do this while keeping the quality of the image as high as possible?

Original source