.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Windows Application >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Image Conversion in C#

Posted By:Jean Paul       Posted Date: May 12, 2011    Points: 200    Category: Windows Application    URL: http://www.dotnetspark.com  

Image Conversion in C#
 

Image Conversion in C#

I have found in forums, that people are searching for conversion of images between different formats.

In this article I am going to show the existing Image conversion libraries in .Net. 

Loading an Image

We can load the image from a file using Image.FromFile()

Eg: If we need to convert a image.jpg file to image.png - specify the source path in the above method

Saving an Image

The Image class contains a method Save() which can do the conversion as well.  The image type can be specified using the ImageFormat class.

For saving the above file we can use

image.Save("converted.png", ImageFormat.Png);

 

Supported Target Formats

Currently the ImageFormat class supports the following image formats:

·         Jpeg

·         Gif

·         Png

·         Bmp

·         Emf

·         Exif

·         Icon

·         MemoryBmp

·         Tiff

·         Wmf

I think it is more than enough for our requirements.

Sample Application

You can use the sample application to test the conversion by yourself.  For time being I am using only 4 format.  (Gif, Jpg, Png and Bmp).

On clicking the Load button it will load the image based on type in dialog box.  You can change the type filter in the appearing Image Dialog.

The  Convert To button will prompt with a Save dialog box and you can specify the image name there.  The type of image is determined by the radio buttons in the form.

 


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend