views:

121

answers:

2

(this is related to another question about implementation on iPhone)

I have a large image, size around 30000 (w) x 6000 (h) pixels. You may consider it's like a big map. I assume I need to crop it up into smaller tiles. Questions:

  • what is the tile strategy?

Requirements:

  • whole image (though cropped) can be scrolled up/down/left/right by swipes
  • zoom in (up to pixel-to-pixel) out (down to screen-fit-by-height) by the 2-finger operation
  • memory efficiency by lazy loading tiles

Thanks!

+3  A: 

Check out part 3 of Apple's ScrollViewSuite sample code for an example of how to do this.

Rob Lourens
Oh, I see what you did there. Well I added my answer to the other question too to help anyone who might stumble across it in the future but I don't think you needed two questions for this.
Rob Lourens
+2  A: 

You can use a technique similar to MIP mapping for efficient zooming. In a nutshell, you prepare images that are 1/2, 1/4, 1/8 and so on dimensions of your original image and load/display them according to required zoom level. This will save some scaling computations at the cost of storage space (roughly 1/3 more storage space will be needed).

As for panning the idea could be to have some tiles preloaded around the visible area. If a user is panning in a particular direction the panning speed could taken into account to preload more tiles in that direction.

frgtn
Any suggestion on specific tile cutting guideline (e.g. width x height? no. of tiles to loaded _around_ the viewable tiles) based on the 30000 6000 480 320 numbers?
ohho
I would just try it and see what works based on how long it takes to load images and how the memory is constrained.
Rob Lourens
I totally agree with Rob, you could start at 480x320 tiles and maybe try 120x80 to see if it improves responsiveness. Code to generate and use arbitrarily sized tiles would help in this case.
frgtn