How to convert PNG to BMP at runtime?

 ̄綄美尐妖づ 提交于 2019-12-10 10:17:57

问题


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.


回答1:


You can save to stream

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



回答2:


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)


来源:https://stackoverflow.com/questions/5182178/how-to-convert-png-to-bmp-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!