开发者

.NET image.Save, what format is the file saved in?

开发者 https://www.devze.com 2023-02-10 20:45 出处:网络
When I use, e.g. in C# the image 开发者_如何学Pythonclass which implements the Save method, what format will the file be?

When I use, e.g. in C# the image 开发者_如何学Pythonclass which implements the Save method, what format will the file be? I assume it will be what I enter to save dialog but what if I enter some nonsense extension?


EDIT: BMP is the default format.

Seems that PNG is the default format. The Save() method does provide overrides to specify different formats.

 Image.Save("c:\\myimage.gif", System.Drawing.Imaging.ImageFormat.Gif);

The file extension has no bearing on the actual image format used.

http://msdn.microsoft.com/en-us/library/ktx83wah.aspx


If you don't specify format the image will be saved to the format returned by Image.RawFormat Property. This means that it does not matter what you enter in the filename. The RawFormat property returns the format returned by native GdipGetImageRawFormat function which should correspond to the current format of the image.

0

精彩评论

暂无评论...
验证码 换一张
取 消