views:

839

answers:

3
+1  Q: 

png to bmp

is there anyway that i can convert a png to a bmp in c#

i want to download a image then convert it to a bmp then set it as the desktop background

i have the downloading bit and the background bit done

i just need to convert the png to a bmp

+7  A: 
Image Dummy = Image.FromFile("image.png");
Dummy.Save("image.bmp", ImageFormat.Bmp);
arbiter
do i need to add any name spaces?
Shuttleu
You will need to add references to System.Drawing.And namespace System.Drawing.Imaging would be nice too
BigBlondeViking
ImageFormat class located in the System.Drawing.Imaging namespace.
arbiter
apparently those namespaces dont existhttp://stackoverflow.com/questions/1060600/what-namespaces-are-needed-for-this-piece-of-code-c
Shuttleu
A: 

Have you tried this?

Image imgFile = Image.FromFile(aFileName);
imgFile .Save(strOutFileName, ImageFormat.Bmp);
Miky Dinescu
A: 

Certainly. You'd want to load up a Bitmap object with your png:

Bitmap myBitmap = new Bitmap("mypng.png");

Then save it:

myBitmap.Save("mybmp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
byte