tags:

views:

47

answers:

2

Hi there, I'm working with an image using System.Drawing.Image and I would like to know if I can get the type of it (ex: gif, jpeg...)

Image myImage;
format = myImage.SomethingThatTellsTheImageFormat;

or at least, is there some way to say if it's .gif or not

tks

+5  A: 

Although I'm not a C# user, the API seems to suggest that the RawFormat property is the way to go. The RawFormat property is an ImageFormat, which you can then compare to the (public) static properties of ImageFormat.

Stephen
yes, it's by using the RawFormat property, comparing guid ids ex: myImage.RawFormat.Guid == ImageFormat.Gif.Guid =)
DJPB
+2  A: 

Just as little extension to Stephen's answer: The RawFormat can easily be compared with the public static properties of System.Drawing.Imaging.ImageFormat.

Florian Reischl
Thanks Florian, I have edited my answer to include your expansion (just to have them both in one answer). Please enjoy this upwards orange arrow.
Stephen