Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HUGE image to show on the iPhone

Tags:

xcode

ios

iphone

Ok, here's my problem. I have a HUGE jpg file, 18000 x 18000 pixels 41MB in size. If you really need to know, it's a map of a section of the country with services.

My project is really simple. I just need to be able to zoom and display this granddaddy size image. All the way from aspect fit to 100% on the iPhone. I'm not too sure if this can be done or how long it will take. Would appreciate any insights.

I have tried using imageView but I read that it really shouldnt exceed 1024 x 1024. That is way below what I have. If you have an idea how to go about doing this, please share!

like image 271
Paul Bang-Jensen Avatar asked Dec 02 '22 00:12

Paul Bang-Jensen


1 Answers

You should split the image into tiles, at a range of magnifications. Calculate and build these off-line, and ship them as individual files in the app bundle. Given the zoom in your display, pick the closest zoom size. You then select which tiles are needed to cover the screen, and make a grid of them. As the user zooms, select the appropriate tile size.

The benefit of this is that you don't ever have to load HUGE files into memory, only as much as needed.

This is how Google maps does it.

Can't give you any code, sorry!

like image 100
Joe Avatar answered Dec 14 '22 22:12

Joe