|
|
"Fast Image Information", by code_666
|
At the moment, the only way to get an image's width/height is to first load it and then use the ImageWidth()/ImageHeight() commands. If you are using code that makes a decision whether to use an image based on this information, loading the whole image into memory - just to then discard it - is slow and wasteful, not to mention time consuming!
What my code does is to jump into the file stream and pull out the information directly and then calculate the width and the height - thus negating the need to load the whole file into memory first. This is a much faster way of doing things, especially with large images.
An added bonus is that the code does not determine the image's type based on the file extension you feed the function, it checks the file for it's signature and then acts accordingly. Room has been left in the logic for coders to add their own formats and/or formats not supported by this code. The code's logic differentiates between header and footer signatures, primarily for ease of use and speed.
Code is free to use - all I ask is for recognition in the program. |
| Code | | | |