![]() |
|
Image Format
(Graphics; VB.NET)
I always wanted that the functionality to convert an image from one format to another should be available in the programming language itself. This dream has come true with .NET. There are many applications (dealing with images) in which we might want to save an image of any format in some other format (example: bmp to jpg is very common as it decreases the file size considerably without significant loss of quality). This can be done very easily in .NET. We can accomplish this using the Save method of Bitmap object.The following code reads a bmp image file into a bitmap object and then saves it back in jpg format. Dim btmp As New Bitmap("C:\myimage.bmp") btmp.Save("C:\myimage.jpg",System.Drawing.Imaging.ImageFormat.Jpeg) The first line loads the bitmap from the file myimage.bmp located in C:\ into a bitmap object - btmp. The second line saves the loaded bitmap in Jpeg format with myimage.jpg as filename. Other formats specified in ImageFormat class include bmp, gif, jpeg, tiff, png, etc. Please send your feedback at rahul@coder000.com |