Graphics Reference
In-Depth Information
Unlike most image formats available on iOS, PVRTC images can be drawn directly to the
screen without needing to be decompressed beforehand. This means that there is no
decompression step after loading, and the size in memory is substantially smaller than any
other image type (as little as one-sixteenth of the size, depending on the compression
settings used).
There are several disadvantages to PVRTC, however:
Although they consume less RAM when loaded, PVRTC files are larger than JPEG
and may even be larger than PNG (depending on the contents) because the
compression algorithm is optimized for performance rather than file size.
PVRTC images must be exactly square and have power-of-two dimensions. If the
source image doesn't meet these requirements, you'll have to stretch it or pad it with
empty space before converting to PVRTC.
The quality is not fantastic, especially for images with transparency. It generally
looks like a heavily compressed JPEG file.
PVRTC images cannot be drawn using Core Graphics, displayed in an ordinary
UIImageView or used directly as a layer's contents . You have to load PVRTC
images as an OpenGL texture and then map it onto a pair of triangles for display in a
CAEAGLLayer or GLKView .
Creating an OpenGL context for drawing a PVRTC image is quite expensive initially.
Unless you plan to draw a lot of images into the same context, this may cancel out the
performance benefit of using PVRTC.
PVRTC images use an asymmetric compression algorithm. Although they
decompress almost instantly, compressing them takes a phenomenally long time. On
a modern, fast desktop Mac, it can take a minute or more to generate a single large
PVRTC image. It is therefore not viable to generate them on-the-fly on an iOS
device.
If you don't mind working with OpenGL, and have the luxury of generating your images in
advance, PVRTC offers amazing loading performance compared to any other format
available on iOS. For example, it's possible to load and display a 2048×2048 PVRTC
image on the main thread in less than one-sixtieth of a second on a modern iOS device
(that's more than big enough to fill a Retina iPad screen), avoiding a lot of the threading
and caching complexity required when loading other formats.
Xcode includes a command line tool called texturetool for generating PVRTC images, but
it's awkward to access (it's inside the Xcode application bundle) and rather limited in
functionality. A better option is to use the Imagination Technologies PVRTexTool, which
you can download for free as part of the PowerVR SDK from
http://www.imgtec.com/powervr/insider/sdkdownloads.
After you've installed PVRTexTool, you can convert a suitably sized PNG image to a
PVRTC file by using the following command in the Terminal:
Search WWH ::




Custom Search