3

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.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Yanshof
  • 9,659
  • 21
  • 95
  • 195

2 Answers2

7

You can save to stream

using(MemoryStream stream = new MemoryStream())
{
    Dummy.Save(stream, ImageFormat.Bmp); 
}
Stecya
  • 22,896
  • 10
  • 72
  • 102
3

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)
Community
  • 1
  • 1
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164