How to convert PNG to BMP at runtime?

I need to convert a PNG file to a BMP file at runtime.

I can not do it like

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

because I can not save the bmp image on the local disk as a file.

Thanks for any help.

+3
source share
2 answers

You can save to stream

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

The exact answer given here.

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

Since you do not want to follow this method, you can do it the way you answered Stecya.
Just do it like that.

Stream stream;  
Dummy.save(stream, ImageFormat.Bmp)
+3
source

Source: https://habr.com/ru/post/1796061/


All Articles