Click here to Skip to main content
6,594,932 members and growing! (15,584 online)
Email Password   helpLost your password?
Multimedia » General Graphics » Image classes     Intermediate License: The Microsoft Public License (Ms-PL)

A C# Image Converter

By George Anescu

Presenting a smal C# Windows Application for converting images between different graphical formats
C#, Windows, .NET 1.0, Dev
Posted:25 Sep 2001
Updated:3 Jan 2003
Views:148,255
Bookmarked:48 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
23 votes for this article.
Popularity: 4.49 Rating: 3.30 out of 5
6 votes, 35.3%
1
1 vote, 5.9%
2
2 votes, 11.8%
3
1 vote, 5.9%
4
7 votes, 41.2%
5

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)

About the Author

George Anescu


Member

Occupation: Web Developer
Location: Romania Romania

Other popular General Graphics articles:

  • A flexible charting library for .NET
    Looking for a way to draw 2D line graphs with C#? Here's yet another charting class library with a high degree of configurability, that is also easy to use.
  • CxImage
    CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
  • 3D Pie Chart
    A class library for drawing 3D pie charts.
  • Barcode Image Generation Library
    This library was designed to give an easy class for developers to use when they need to generate barcode images from a string of data.
  • ImageStone
    An article on a library for image manipulation.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 22 of 22 (Total in Forum: 22) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmemberGuy Baseke5:24 21 Sep '09  
QuestionUsing Win32 calls for Image conversion. Pinmemberkavitesh21:57 1 Apr '08  
QuestionOverwrting the file casues JIT Error Pinmemberwaliaps6:11 14 Dec '06  
QuestionQuery Pinmembermak_gh20:58 22 Feb '06  
Generalgif patent expired Pinmemberraloth45611:38 27 Aug '04  
GeneralOther formats PinmemberAnonymous3:16 8 Mar '02  
GeneralRe: Other formats PinmemberChristian Graus2:02 4 Jan '03  
GeneralWhich version of Framework PinmemberAnonymous8:23 17 Oct '01  
General[Message Deleted] PinsussAnonymous10:36 30 Aug '02  
GeneralRe: Which version of Framework PinmemberGeorge Anescu12:09 28 Dec '02  
GeneralGIF PinmemberChris Losinger5:46 26 Sep '01  
GeneralRe: GIF PinmemberGeorge Anescu6:41 26 Sep '01  
GeneralRe: GIF PinmemberAnonymous12:23 5 Oct '01  
GeneralRe: GIF PinmemberChris Losinger13:32 5 Oct '01  
GeneralRe: GIF PinmemberAnonymous7:11 11 Oct '01  
GeneralRe: GIF PinmemberChristian Graus1:59 4 Jan '03  
GeneralRe: GIF PinmemberMike Stevenson7:24 11 Oct '01  
GeneralRe: GIF PinmemberChristian Graus2:00 4 Jan '03  
GeneralRe: GIF Pinmemberfadi9:43 9 Jan '02  
GeneralGIF: wrong. PinmemberChris Losinger9:50 9 Jan '02  
GeneralRe: GIF Pinmemberrendle6:26 4 Apr '02  
GeneralRe: GIF Pinmemberabstractsagacity0:07 21 Aug '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 3 Jan 2003
Editor: Chris Maunder
Copyright 2001 by George Anescu
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project