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

O

Onur Güzel

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
 
O

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top