5,699,431 members and growing! (15,748 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, .NETVisual Studio, VS.NET2002, Dev

Posted: 25 Sep 2001
Updated: 3 Jan 2003
Views: 137,009
Bookmarked: 43 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
22 votes for this Article.
Popularity: 4.67 Rating: 3.48 out of 5
5 votes, 31.3%
1
1 vote, 6.3%
2
2 votes, 12.5%
3
1 vote, 6.3%
4
7 votes, 43.8%
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



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.
  • Really cool visual FX
    A set of classes for doing stunning visual effects, including water, plasma and fire.
  • ImageStone
    An article on a library for image manipulation.
Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 21 of 21 (Total in Forum: 21) (Refresh)FirstPrevNext
QuestionUsing Win32 calls for Image conversion.memberkavitesh21:57 1 Apr '08  
QuestionOverwrting the file casues JIT Errormemberwaliaps6:11 14 Dec '06  
QuestionQuerymembermak_gh20:58 22 Feb '06  
Generalgif patent expiredmemberraloth45611:38 27 Aug '04  
GeneralOther formatsmemberAnonymous3:16 8 Mar '02  
GeneralRe: Other formatsmemberChristian Graus2:02 4 Jan '03  
GeneralWhich version of FrameworkmemberAnonymous8:23 17 Oct '01  
GeneralRe: Which version of FrameworksussAnonymous10:36 30 Aug '02  
GeneralRe: Which version of FrameworkmemberGeorge Anescu12:09 28 Dec '02  
GeneralGIFmemberChris Losinger5:46 26 Sep '01  
GeneralRe: GIFmemberGeorge Anescu6:41 26 Sep '01  
GeneralRe: GIFmemberAnonymous12:23 5 Oct '01  
GeneralRe: GIFmemberChris Losinger13:32 5 Oct '01  
GeneralRe: GIFmemberAnonymous7:11 11 Oct '01  
GeneralRe: GIFmemberChristian Graus1:59 4 Jan '03  
GeneralRe: GIFmemberMike Stevenson7:24 11 Oct '01  
GeneralRe: GIFmemberChristian Graus2:00 4 Jan '03  
GeneralRe: GIFmemberfadi9:43 9 Jan '02  
GeneralGIF: wrong.memberChris Losinger9:50 9 Jan '02  
GeneralRe: GIFmemberrendle6:26 4 Apr '02  
GeneralRe: GIFmemberabstractsagacity0: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-2008
Web11 | Advertise on the Code Project