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!

Community
  • 1
  • 1
ohho
  • 50,879
  • 75
  • 256
  • 383

2 Answers2

3

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

Rob Lourens
  • 15,081
  • 5
  • 76
  • 91
  • 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 Apr 28 '10 at 02:12
2

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.

Saulius Žemaitaitis
  • 2,956
  • 3
  • 29
  • 36
  • 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 Apr 28 '10 at 03:52
  • 1
    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 Apr 28 '10 at 16:00
  • 1
    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. – Saulius Žemaitaitis Apr 29 '10 at 17:18