png to bmp in C#
Asked Answered
G

3

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.

Gauguin answered 29/6, 2009 at 20:44 Comment(1)
If you're using Vista or Windows 7 they can deal with PNGs directly; no need to convert.Wren
F
32
Image Dummy = Image.FromFile("image.png");
Dummy.Save("image.bmp", ImageFormat.Bmp);
Foin answered 29/6, 2009 at 20:47 Comment(4)
do i need to add any name spaces?Gauguin
You will need to add references to System.Drawing. And namespace System.Drawing.Imaging would be nice tooFaugh
ImageFormat class located in the System.Drawing.Imaging namespace.Foin
apparently those namespaces dont exist #1061100Gauguin
N
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);
Nativity answered 29/6, 2009 at 20:51 Comment(0)
O
1

Have you tried this?

Image imgFile = Image.FromFile(aFileName);
imgFile .Save(strOutFileName, ImageFormat.Bmp);
Orenorenburg answered 29/6, 2009 at 20:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.