开发者

Generating dynamic tiles for CATiledLayer

开发者 https://www.devze.com 2023-01-14 15:40 出处:网络
I\'ve seen the WDC2010 Session 104 for using scrollviews and CATiledLayers, which is all pretty cool. But I\'m not sure about the generation of the tile images. The examp开发者_运维问答le had the frog

I've seen the WDC2010 Session 104 for using scrollviews and CATiledLayers, which is all pretty cool. But I'm not sure about the generation of the tile images. The examp开发者_运维问答le had the frog tile pictures already created. But if I have a photo app where I am taking my own photos, I will need to create the tiles myself and I'm not sure of the best approach to take.

Easiest method would be as soon as I take a photo and store it, I do some image manipulation and create all the possible tiles I need. But that means for every photo, I'm storing a lot more files and using more file space.

Just before I need the photo, I create the tiles into a temp directory. When I've finished the viewing part I can delete that temp directory. At least I'm only using the extra file space when viewing the photos. But I'd be concerned about loading the image to create tiles as to whether I introduce a delay which is noticeable to the user.


You wouldn't need to save off the tiled images. Basically, you would create the UIImage/CGImage based on the rect being displayed.

I have done something similar here and it works quite well, the bonus is that it is very efficient with memory. I dynamically generate the CGImage (the small tile from the large image) based on the rect being displayed and the TiledLayer removes it from memory when it dumps the rect. I never save the CGImage to a file.

The disadvantage with this approach is that it introduces latency in the rendering... Not good for games on an iphone 3g.

0

精彩评论

暂无评论...
验证码 换一张
取 消