View Full Version : smart to load up a graphics file

08-08-2000, 01:48 AM
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?

08-08-2000, 04:44 AM
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.

08-08-2000, 10:03 AM
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! http://www.opengl.org/discussion_boards/ubb/smile.gif