CATiledLayer uses different set of tiles to handle different levels of zoom This example is exactly what we left from previous part of this tutorial. Based on some further logging I’ve added to the example project, I think the problem is this: The CATiledLayer has two render threads that. Let’s take a look at a CATiledLayer demo. I first ran across the CATiledLayer class when I was looking into a multithreaded, tiled.
|Published (Last):||27 July 2008|
|PDF File Size:||3.49 Mb|
|ePub File Size:||9.64 Mb|
|Price:||Free* [*Free Regsitration Required]|
One of the biggest challenges I faced writing Pholio was handling large images. Using the Camera Connection Kitphotographers will import full-resolution images onto their iPads.
CATiledLayer (Part 1)
Full-resolution photos can use a lot of memory when displayed — roughly 4 megabytes per megapixel. So each image from the 16 megapixel D, for example, will need 64 MB of RAM to show the picture at full resolution. If the catileelayer is using an iPad 1, with MB of RAM, the device will be straining to show even one full resolution photo.
Smooth scrolling requires you load more than one photo into memory, though.
So what do you do? Never show full resolution photos! The iPad screen has a resolution of a little under one megapixel. Your challenge as a programmer: Efficiently turn the 16 MP image that the user gives you to the 1MP image you need for display. This article shares some tips I learned writing Pholio on managing large images.
My first attempt at handling large images relied upon tiling. Tiling holds a lot of promise. You get the efficient memory use cariledlayer small pictures, but customers can still zoom in and see the detail of the large image.
If you break your high-resolution image into tiles and load only the tiles you need, you can avoid the memory hit of loading the entire high resolution image. The following diagram gives you an idea of Pholio used tiling for large photos.
CATiledLayer – Core Animation | Apple Developer Documentation
Starting with the full resolution image, I computed how exqmple total levels of detail I wanted to provide. The highest level of detail was the full resolution image; the lowest level of detail is the image that would just fill the screen.
Each tile was saved as an individual PNG.
You can find the code at IPPhoto. At its core, I use code from the great tutorial at Cocoa is my Girlfriend.
Once I had the photo broken down into tiles, I relied on a simple custom UIView subclass to show the photo. I shipped Version 2. On demand, I would spawn a background catilrdlayer to generate tiles of photos.
I carefully prioritized generating tiles for the lowest level of detail first, so I would catioedlayer responsiveness to the user. Everything worked great in my tests and on my device. I was proud of what I wrote. A customer contacted me telling me that the program was crashing. After a few emails back and forth, I figured out why: He was working with full-resolution 10 MP images on an iPad 1. I did all my device testing on an iPad 2, which has twice the memory of the iPad 1.
I started testing with full resolution photos on an iPad 1, and I found what the customer had discovered. The process of tiling the photo made it too easy to exhaust memory on the device.
I needed a new approach. In my next article, I will describe the more conservative approach to large images that I use in version 2. Tiling My first attempt at handling large images relied upon tiling.
The iPad 1 After Version 2.