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
Bmp - Bitmap image format (extension
Emf - Enhanced Windows metafile image format
Exif - Exchangable Image Format
Gif - Graphics Interchange Format image format (extension
Icon - Windows icon image format (extension
Jpeg - Joint Photographic Experts Group image format (extensions
MemoryBmp - Specifies a memory bitmap image format
Png - Specifies the W3C Portable Network Graphics image format (extension
Tiff - Tag Image File Format (extension
Wmf - Windows metafile image format (extension
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";
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.
28 Dec 2002 - Update to VS.NET release with the code provided by M.H. Thanks!
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.