0

Happy New Year,

I am writing an app where the user searches for high res images online and then downloads these large images. I need to show these in a UIScrollView.

On the Apple dev site I found the WWDC 2010 Session 104 on UIScrollViews that explains how I can use CATiledLayer with a manually created set of tiles at the various zoom levels.

Is there a way to generate the tiles programmatically from the downloaded high res image file?

Any recommendations?

Thanks

2 Answers2

0

Starting with a CGImage (UIImage has a readonly CGImage property if you're starting with a UIImage) you can use CGImageCreateWithImageInRect to create tiles from the original.

To create tiles at different zoom levels you'll probably need to draw your scaled CGImage to a graphics context and use UIGraphicsGetImageFromCurrentImageContext to get a UIImage containing the drawn image which you can then write out to some cache. See "Creating and Drawing Images" in the Drawing and Printing Guide for iOS.

Jonah
  • 17,918
  • 1
  • 43
  • 70
0

There's an example in a book covering Core Animation ( link ) covering just that. Besides, the book is worth the money for the other stuff as well :-)

moritz
  • 2,448
  • 1
  • 20
  • 25