gpt4 book ai didi

c# - 为什么位图保存为PNG

转载 作者:太空宇宙 更新时间:2023-11-03 18:21:12 27 4
gpt4 key购买 nike

我的应用程序中有位图对象。为什么Save()方法保存的是PNG格式的文件而不是BMP

Bitmap currentImmage;
...
currentImmage.Save("image.bmp");

最佳答案

来自文档

Save(String)

If no encoder exists for the file format of the image, the Portable Network Graphics (PNG) encoder is used. When you use the Save method to save a graphic image as a Windows Metafile Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is saved as a Portable Network Graphics (PNG) file. This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that you can use to save files as .wmf or .emf files.

改用

Save(String, ImageFormat)

Saves this Image to the specified file in the specified format.

ImageFormat Class

Specifies the file format of the image.

示例

currentImmage.Save("image.bmp",ImageFormat.Bmp);

关于c# - 为什么位图保存为PNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53099512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com