How to tile a 30000 x 6000 image for a 480 x 320 screen?

天大地大妈咪最大 提交于 2019-12-01 08:02:19

问题


(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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!