I'm writing a method that needs to save a System.Drawing.Image
to a file. Without knowing the original file the Image
was created from, is there anyway to determine what file extension it should have?
The best solution I've come up with is to use a Switch/Case statement with the value of Image.RawFormat.
Does it even matter that I save the Image
in it's original format? Is an Image
generated from a PNG any different from say one generated from a JPEG? Or is the data stored in an Image
object completely generic?
Yes, it definitely matters because different fileformats support different features such as compression, multiple frames, etc.
I've always used a switch statement like you have, perhaps baked into an extension method or something.