How to convert PNG to BMP at runtime?

Yanshof picture Yanshof · Mar 3, 2011 · Viewed 8.8k times · Source

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.

Answer

Stecya picture Stecya · Mar 3, 2011

You can save to stream

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