Mocco
Mocco

Reputation: 1223

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

When I use, e.g. in C# the image class 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?

Upvotes: 4

Views: 2740

Answers (2)

Craigt
Craigt

Reputation: 3580

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

Upvotes: 6

Giorgi
Giorgi

Reputation: 30873

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.

Upvotes: 3

Related Questions