Click here to Skip to main content
15,173,985 members
Articles / Programming Languages / C#
Posted 25 Sep 2001


58 bookmarked

A C# Image Converter

Rate me:
Please Sign up or sign in to vote.
3.29/5 (19 votes)
3 Jan 2003Ms-PL1 min read
Presenting a smal C# Windows Application for converting images between different graphical formats

Sample Image - ImagConvert.jpg


The conversion between different graphical image formats using the C# programming language and the .NET Framework is very easy in comparison with the Windows API case where no direct support for such an operation is provided. You can open any image file format from the ones specified by a group of properties of ImageFormat class:

  • Bmp - Bitmap image format (extension .bmp)
  • Emf - Enhanced Windows metafile image format
  • Exif - Exchangable Image Format
  • Gif - Graphics Interchange Format image format (extension .gif)
  • Icon - Windows icon image format (extension .ico)
  • Jpeg - Joint Photographic Experts Group image format (extensions .jpg, .jpeg)
  • MemoryBmp - Specifies a memory bitmap image format
  • Png - Specifies the W3C Portable Network Graphics image format (extension .png)
  • Tiff - Tag Image File Format (extension .tif)
  • Wmf - Windows metafile image format (extension .wmf)

ImageFormat class is in the System.Drawing.Imaging namespace. The following code snippet is showing how it is done:

string strFileName = "FileName.jpg";
Bitmap bitmap = new Bitmap(strFileName);

Later you can save the bitmap in another graphical format specifying the new file name and graphical format like in the following code snippet:

strFileName = "FileName.gif";
bitmap.Save(oStrFileName, ImageFormat.Gif);

The source code of a fully operational Image Converter application is provided in the attached project I am interested in any opinions and new ideas about this implementation.

Updates History

28 Dec 2002 - Update to VS.NET release with the code provided by M.H. Thanks!


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

George Anescu
Web Developer
Romania Romania
No Biography provided

Comments and Discussions

GeneralI tried to convert a EMF format file to a Bitmap file. the background turns to black Pin
hawkgao012925-Jul-10 21:35
Memberhawkgao012925-Jul-10 21:35 
GeneralMy vote of 1 Pin
Guy Baseke21-Sep-09 5:24
MemberGuy Baseke21-Sep-09 5:24 
QuestionUsing Win32 calls for Image conversion. Pin
kaviteshsingh1-Apr-08 21:57
Memberkaviteshsingh1-Apr-08 21:57 
QuestionOverwrting the file casues JIT Error Pin
waliaps14-Dec-06 6:11
Memberwaliaps14-Dec-06 6:11 
QuestionQuery Pin
makarandg22-Feb-06 20:58
Membermakarandg22-Feb-06 20:58 
Generalgif patent expired Pin
ralothh27-Aug-04 11:38
Memberralothh27-Aug-04 11:38 
GeneralOther formats Pin
8-Mar-02 3:16
suss8-Mar-02 3:16 
GeneralRe: Other formats Pin
Christian Graus4-Jan-03 2:02
mveChristian Graus4-Jan-03 2:02 
GeneralWhich version of Framework Pin
17-Oct-01 8:23
suss17-Oct-01 8:23 
General[Message Deleted] Pin
Anonymous30-Aug-02 10:36
MemberAnonymous30-Aug-02 10:36 
GeneralRe: Which version of Framework Pin
George Anescu28-Dec-02 12:09
MemberGeorge Anescu28-Dec-02 12:09 
GeneralGIF Pin
Chris Losinger26-Sep-01 5:46
professionalChris Losinger26-Sep-01 5:46 
GeneralRe: GIF Pin
George Anescu26-Sep-01 6:41
MemberGeorge Anescu26-Sep-01 6:41 
GeneralRe: GIF Pin
5-Oct-01 12:23
suss5-Oct-01 12:23 
GeneralRe: GIF Pin
Chris Losinger5-Oct-01 13:32
professionalChris Losinger5-Oct-01 13:32 
GeneralRe: GIF Pin
11-Oct-01 7:11
suss11-Oct-01 7:11 
GeneralRe: GIF Pin
Christian Graus4-Jan-03 1:59
mveChristian Graus4-Jan-03 1:59 
GeneralRe: GIF Pin
Mike Stevenson11-Oct-01 7:24
MemberMike Stevenson11-Oct-01 7:24 
GeneralRe: GIF Pin
Christian Graus4-Jan-03 2:00
mveChristian Graus4-Jan-03 2:00 
GeneralRe: GIF Pin
fadi9-Jan-02 9:43
Memberfadi9-Jan-02 9:43 
GeneralGIF: wrong. Pin
Chris Losinger9-Jan-02 9:50
professionalChris Losinger9-Jan-02 9:50 
GeneralRe: GIF Pin
rendle4-Apr-02 6:26
Memberrendle4-Apr-02 6:26 
GeneralRe: GIF Pin
abstractsagacity21-Aug-04 0:07
Memberabstractsagacity21-Aug-04 0:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.