23

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Shuttleu
  • 243
  • 1
  • 2
  • 6

3 Answers3

31
Image Dummy = Image.FromFile("image.png");
Dummy.Save("image.bmp", ImageFormat.Bmp);
arbiter
  • 9,447
  • 1
  • 32
  • 43
11

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);
dreadwail
  • 15,098
  • 21
  • 65
  • 96
1

Have you tried this?

Image imgFile = Image.FromFile(aFileName);
imgFile .Save(strOutFileName, ImageFormat.Bmp);
Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151