Graphics Reference
In-Depth Information
//set up cell
NSString
*imageName =
self
.
items
[indexPath.
row
];
cell.
textLabel
.
text
= imageName;
cell.
detailTextLabel
.
text
=
@"Loading..."
;
//load image
[
self
loadImageAtIndex
:indexPath.
row
];
return
cell;
}
@end
The PNG and JPEG compression algorithms are tuned for different image types: JPEG
works well for noisy, imprecise images like photographs; and PNG is better suited to flat
areas of color, sharp lines, or exact gradients. To make the benchmark fairer, we'll run it
with a couple of different images: a photograph and a rainbow color gradient. The JPEG
versions of each image were encoded using the default Photoshop “high-quality” setting of
60%. Figure 14.5 shows the results.
Figure 14.5
Relative loading performance for different types of images
As the benchmark demonstrates, for PNG-unfriendly images, JPEGs are consistently faster
to load than PNGs of the same dimensions, unless the images are very small. For PNG-
friendly images, they are still better for medium-to-large images.