Click here to Skip to main content
Click here to Skip to main content

A C# Image Converter

, 3 Jan 2003 Ms-PL
Rate this:
Please Sign up or sign in to vote.
Presenting a smal C# Windows Application for converting images between different graphical formats

Sample Image - ImagConvert.jpg

Introduction

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 ImagConvert.zip. 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!

License

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

Share

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 Pinmemberhawkgao012925-Jul-10 21:35 
GeneralMy vote of 1 PinmemberGuy Baseke21-Sep-09 5:24 
QuestionUsing Win32 calls for Image conversion. Pinmemberkavitesh1-Apr-08 21:57 
QuestionOverwrting the file casues JIT Error Pinmemberwaliaps14-Dec-06 6:11 
QuestionQuery Pinmembermak_gh22-Feb-06 20:58 
Generalgif patent expired Pinmemberraloth45627-Aug-04 11:38 
GeneralOther formats PinmemberAnonymous8-Mar-02 3:16 
GeneralRe: Other formats PinmemberChristian Graus4-Jan-03 2:02 
GeneralWhich version of Framework PinmemberAnonymous17-Oct-01 8:23 
General[Message Deleted] PinsussAnonymous30-Aug-02 10:36 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 4 Jan 2003
Article Copyright 2001 by George Anescu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid