Android Question Most efficient way to get image aspect ratio

MrKim

Well-Known Member
Licensed User
Longtime User
I plan to use LoadBitmapResize to load images, unfortunately before doing that you need the aspect ratio to tell it what size to get. The only suggestion I have found here for getting the aspect ratio involves loading the entire file into a bitmap and using that to get the dmensions. As photo files can be quite large (and getting larger all the time) this seems very inefficient. I know in windows if you hover over an image file (.jpg/.png//bmp) it will display the size. Isn't there a way to read the dimensions from the file rather than loading the whole thing?

Thanks
 

sorex

Expert
Licensed User
Longtime User
you can always do a binary read of the jpg header. I can spot the dimension at 0xC2 & 0xC4 in a jpg that I have here.
not sure if it varies in position tho.

but when you use xui loadbitmapresize you have this keep aspect ratio option that you just have to set to true.
(not 100% safe when needing 100% pixel perfect tho as it varies a little over systems)
 
Upvote 0
Top