10-02-2009 07:48 PM
Is there a way to get the hieght and width of an bitmap file, like jpg or png, without loading the entire image file first.
Solved! Go to Solution.
10-03-2009 08:21 AM
While you can not access the width and height of the jpg or png without accessing the file, you can gain this information without accessing the whole file. A PNG for example (in raw hex) does indicate the width and height of the image it contains. The first 21 bytes contain the file specific information such as name, etc, however right after the IHDR header the first 4 bytes indicate Width and the next 4 bytes indicate Height. So this way you only need to read the first 29 bytes of the PNG to be able to get its dimensions, which while it still requires file access is considerably easier.
10-03-2009 02:00 PM
Excellent. Very specific information. Thanks for your assistance!
neeraj asked why I was concerned. I find that I REALLY have to pay attention to resources such as memory use, I/O use, and CPU use, or I can slow down the Blackberry to a crawl making it useless to the end user. The little things may not seem like much by themselves, but they can really add up. The way I originally coded my program, it took over a minute to load. So I must consider the time it would take to open several large bitmap files in a row, when all I need to know is there size.