问题
(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!
回答1:
Check out part 3 of Apple's ScrollViewSuite sample code for an example of how to do this.
回答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.
来源:https://stackoverflow.com/questions/2726335/how-to-tile-a-30000-x-6000-image-for-a-480-x-320-screen