Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 291
Cyclone Avatar asked Sep 06 '09 01:09

Cyclone


2 Answers

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.

like image 71
Kibbee Avatar answered Sep 30 '22 10:09

Kibbee


Check out the Drawing.Bitmap.Save() method. I recommend saving as PNG - it's lossless and achieves reasonable compression. See the Imaging.ImageFormat enum - this is how you specify the image type you want.

like image 33
Charlie Salts Avatar answered Sep 30 '22 10:09

Charlie Salts