Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Are you asking how to create thumbnails from larger images, or about how to build a view controller which displays them nicely?</p> <p><strong>Building a view controller:</strong></p> <p>You could use <code>TTPhotoViewController</code> from <a href="http://github.com/joehewitt/three20/tree/master" rel="nofollow noreferrer">the Three20 project</a> (<a href="http://joehewitt.com/post/the-three20-project/" rel="nofollow noreferrer">description</a>), which acts similarly to the iPhone's built in camera roll to view images.</p> <p>You can look at <a href="https://developer.apple.com/iphone/library/samplecode/Scrolling/index.html" rel="nofollow noreferrer">the <code>Scrolling</code> sample code</a> from apple, referred to in <a href="https://stackoverflow.com/questions/652644/better-way-to-have-a-photo-slider-thumbnails-on-iphone">this question about using it for thumbnails</a>.</p> <p>If you want to build one yourself, you might consider using a <a href="http://bynomial.com/moriarty/GridView.h.txt" rel="nofollow noreferrer"><code>GridView</code></a> from <a href="http://bynomial.com/moriarty/" rel="nofollow noreferrer">the moriarty library</a>, either as a large grid in a <code>UIScrollView</code>, or on a more efficient row-by-row basis in a <code>UITableView</code>. There's a previous question on <a href="https://stackoverflow.com/questions/1098234/optimized-image-loading-in-a-uiscrollview">optimized image loading in a <code>UIScrollView</code></a>.</p> <p><strong>Creating thumbnails from larger images:</strong></p> <p>The code-easiest way to scale down an image is to simply display it in a <code>UIImageView</code> with a frame set to the smaller size that you want - it's scaled for you.</p> <p>If you want to save a thumbnail, or care about memory usage, you can create a hard-scaled version. The sample code below is taken from <a href="http://ofcodeandmen.poltras.com/2008/10/30/undocumented-uiimage-resizing/" rel="nofollow noreferrer">this blog post</a>, and can be added to <code>UIImage</code> as a category method:</p> <pre><code>- (UIImage*) imageScaledToSize: (CGSize) newSize { UIGraphicsBeginImageContext(newSize); [self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } </code></pre> <p>Finally, here's a previous question on <a href="https://stackoverflow.com/questions/996292/how-to-mask-a-square-image-into-an-image-with-round-corners-in-the-iphone-sdk">masking out round corners on an image</a>, similar to the app icons used on the home screen.</p> <p><em>Added</em></p> <p><strong>Using an image's built-in thumbnail:</strong></p> <p>There's a nice function called <code>CGImageSourceCreateThumbnailAtIndex</code> that understands built-in thumbnails in certain image data formats. You can see some useful sample code for this under <em>Creating a Thumbnail Image from an Image Source</em> in <a href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/ImageIOGuide/imageio_source/ikpg_source.html#//apple_ref/doc/uid/TP40005462-CH218-DontLinkElementID_5" rel="nofollow noreferrer">the Image I/O Programming Guide</a> from Apple.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload