Yanshof
Yanshof

Reputation: 9926

How to convert PNG to BMP at runtime?

I need to convert PNG file to BMP file on runtime.

I can't do it like

Image dummy = Image.FromFile("image.png"); 
dummy.Save("image.bmp", ImageFormat.Bmp); 

because i can't save the bmp image on the local disk as a file.

Thanks for any help.

Upvotes: 3

Views: 10358

Answers (2)

Stecya
Stecya

Reputation: 23266

You can save to stream

using(MemoryStream stream = new MemoryStream())
{
    Dummy.Save(stream, ImageFormat.Bmp); 
}

Upvotes: 7

Saurabh Gokhale
Saurabh Gokhale

Reputation: 46395

Precise answer given here.

Image Dummy = Image.FromFile("image.png");
Dummy.Save("image.bmp", ImageFormat.Bmp);

Since you don't want to follow this method, you can do it the way Stecya answered.
Just do it this way.

Stream stream;  
Dummy.save(stream, ImageFormat.Bmp)

Upvotes: 3

Related Questions