SpeakComputers.com
Home
Software
Electronics
Desktop Computers
Laptops
Games
Handheld Devices
Mobile Phones
Cameras
Camcorders
Printers
Books
Software Downloads 2012 Software Mac Software Security Student Editions Windows 7 Office 2010
ASP.NET C# VB.NET C++ .NET Infragistics DevComponents

Converting images from one format to another in C#

With C# .Net, converting images from one format to another is quick and easy. You can convert image formats from and to of any of the formats listed below.

Name Format Description
Bmp Gets the bitmap image format (BMP).
Emf Gets the enhanced Windows metafile image format (EMF).
Exif Gets the Exchangeable Image File (Exif) format.
Gif Gets the Graphics Interchange Format (GIF) image format.
Icon Gets the Windows icon image format.
Jpeg Gets the Joint Photographic Experts Group (JPEG) image format.
Png Gets the W3C Portable Network Graphics (PNG) image format.
Tiff Gets the Tag Image File Format (TIFF) image format.
Wmf Gets the Windows metafile (WMF) image format.


Converting images from one format to another is really just 2 line of code. (minus error checking).

Image format example.

In the following example, we are going to convert an existing image (png format) to gif format.

Bitmap bmp = new Bitmap("c:\\tmpImage.png");
//existing image.
bmp.Save("c:\\tmpImage.gif", System.Drawing.Imaging.ImageFormat.Gif);
//Saves the converted image to a file in the chosen image format.

Batch image conversion example.
In the following example, we will convert all png images in a directory to tiff images.

DirectoryInfo di = new DirectoryInfo(@"C:\images\png");
foreach (FileInfo file in di.GetFiles())
{
string imagename = Path.GetFileNameWithoutExtension(file.Name);
Bitmap bmp = new Bitmap(file.FullName);
bmp.Save(@"C:\images\tiff\\" + imagename + ".tiff", System.Drawing.Imaging.ImageFormat.Tiff, );
}

Computer Security
AntiVirus Software
Internet Security
Parental Controls
Backup & Recovery
Computer Protection
Anti Malware
Photo & Video
Photo & Video Editing
Video Music
Desktop Publishing
Professional Design
Home Publishing
Clipart
Business & Accounting
Accounting
Payroll
Check Printing
TAX
H&R Block
Microsoft Office
Design
Graphic Design
Home Design
Garden Design
Interior Design
Computer Aided Design
3D Design
Students & Teacher
Adobe
Microsoft Office
Dragon Naturally Speaking
Corel Draw
Serif
Student/Teacher Software
Copy Right 2006 SpeakComputers.com - All Rights Reserved.
Home About Privacy Policy Resouces