.NET image.Save, what format is the file saved in?
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.
精彩评论