smart to load up a graphics file

Hmm… I am currently researching different file formats right now… I have the .bmp and the .tga down, and would like to add support for .png, maybe one other format…

Basically I want to create a function that you can pass a filename to and it should correctly identify the kind of graphics file format it is stored in. An easy way to do is that you can look for the extension (.bmp, .tga etc.) in the filename, but I don’t want to depend on that!

Any suggestions?

Most image file formats have one or more file type identifiers in a header, footer, and/or data block. For some formats it should be very easy to look for as it must always be first in the file stream. Other formats, which lack an identifier are a little tricker in that you will have to first process the “potential header” to see if it makes sense for a given file type, and if it does, assume the file is in the suspected format. Of course, you should always process the header info, to see if it makes sense, even if you do find the identifier, so that you can weed out corrupt files.

yeah… I was think of something I like that, I guess there is no other way, now that I think about it… just resetting the file pointer to the beginning and searching I guess… thanks a lot!

Navreet