article

Change Image Format (jpg, bmp, png)

Email
Submitted on: 1/3/2015 9:09:00 AM
By: Rahul Vyas (coder000) (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: VB.NET
Views: 4876
 
     I always wanted that the functionality to convert an image from one format to another should be available in the programming language itself. This dream has come true with .NET. There are many applications (dealing with images) in which we might want to save an image of any format in some other format (example: bmp to jpg is very common as it decreases the file size considerably without significant loss of quality). This can be done very easily in .NET.

 
						Image Format 
		(Graphics; VB.NET)
		
			

I always wanted that the functionality to convert an image from one format to another should be available in the programming language itself. This dream has come true with .NET. There are many applications (dealing with images) in which we might want to save an image of any format in some other format (example: bmp to jpg is very common as it decreases the file size considerably without significant loss of quality). This can be done very easily in .NET.

We can accomplish this using the Save method of Bitmap object.

The following code reads a bmp image file into a bitmap object and then saves it back in jpg format.

Dim btmp As New Bitmap("C:\myimage.bmp")

btmp.Save("C:\myimage.jpg",System.Drawing.Imaging.ImageFormat.Jpeg)

The first line loads the bitmap from the file myimage.bmp located in C:\ into a bitmap object - btmp.

The second line saves the loaded bitmap in Jpeg format with myimage.jpg as filename.

Other formats specified in ImageFormat class include bmp, gif, jpeg, tiff, png, etc.

Feedback and comments are most welcome


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.