Graphics Reference
In-Depth Information
//combine images
CGImageRef resultRef = CGImageCreateWithMask (image. CGImage , maskRef);
UIImage *result = [ UIImage imageWithCGImage :resultRef];
CGImageRelease (resultRef);
CGImageRelease (maskRef);
//display result
self . imageView . image = result;
}
@end
Using two separate files for each image in this way can be a bit cumbersome. The JPNG
library ( https://github.com/nicklockwood/JPNG) provides an open source, reusable
implementation of this technique that reduces the burden by packing both images into a
single file and adding support for loading hybrid images directly using the +imageNamed:
and +imageWithContentsOfFile: methods.
JPEG 2000
iOS supports various image formats in addition to JPEG and PNG, such as TIFF and GIF,
but for the most part, these are not worth bothering with as they have worse compression,
quality, and performance tradeoffs than JPEG or PNG.
However, in iOS 5, Apple added support for the JPEG 2000 image format. This was added
with little fanfare and is not well known. It's not even properly supported by Xcode—JPEG
2000 images don't show up in Interface Builder.
JPEG 2000 images do work at runtime however (both on device and simulator), and they
offer better image quality than JPEG for a given file size, as well as full support for alpha
transparency. JPEG 2000 images are significantly slower to load and display than either
PNG or JPEG, however, so they're only really a good option if reducing file size is a higher
priority than runtime performance.
It's worth keeping an eye on JPEG 2000 in case it improves significantly in future iOS
releases, but for now, hybrid images offer better performance for a similar file size and
quality.
PVRTC
Every iOS device currently on the market uses an Imagination Technologies PowerVR
graphics chip as its GPU. The PowerVR chip supports a proprietary image compression
standard called PVRTC (PowerVR Texture Compression).
Search WWH ::




Custom Search