convert *.png to *.bmp or *.gif

  • Thread starter Thread starter Pratibha Jalem
  • Start date Start date
I want a code for converting *.png to *. bmp or *.gif and displaying the converted image in image box at run time...in Visual Basic

EggHeadCafe - .NET Developer Portal of Choicehttp://www.eggheadcafe.com/default.aspx?ref=ng

' First you can get initial image in picturebox which will be
converted:
PictureBox1.ImageLocation = "c\image.png''

' Then convert by saving in target format:
' Eg: In jpeg format
PictureBox1.Save("c\image.jpg'',
System.Drawing.Imaging.ImageFormat.Jpeg)

Finally, show converted image by re-assigning ImageLocation property:
PictureBox1.ImageLocation = "c\image.jpg''

Hope this helps,

Onur Güzel
 
' First you can get initial image in picturebox which will be
converted:
PictureBox1.ImageLocation = "c\image.png''

' Then convert by saving in target format:
' Eg: In jpeg format
PictureBox1.Save("c\image.jpg'',
System.Drawing.Imaging.ImageFormat.Jpeg)

Finally, show converted image by re-assigning ImageLocation property:
PictureBox1.ImageLocation = "c\image.jpg''

Hope this helps,

Onur Güzel

And of course, that is based on specifying ImageFormat parameter.
Converting to Jpeg was just a sample. So, you can specify any format
up to what that class supports.
Eg, for GIF: ImageFormat.Gif or for Bmp: ImageFormat.Bmp etc.

See full list:
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.imageformat_properties.aspx

Onur Güzel
 
Back
Top