Other Graphics Libraries
The libraries just discussed form the core functionality of the Mac OS X graphics system. Mac OS X also contains a number of additional libraries that are worth a brief mention here. For more information on these libraries you can consult Apple’s developer documentation.
ATSUI and Cocoa Text
The Apple Type System for Unicode Imaging (ATSUI) and Cocoa Text systems play a vital role in the creation of graphics that contain text. Both ATSUI and the Cocoa Text system are graphics libraries for combining a block of characters, text style information related to those characters, and a region in which the text can be drawn to create a complete image of the text. These libraries are vital to the correct layout and rendering of Unicode text on the Macintosh system. While we will touch upon ATSUI and Cocoa Text in this exploration of Quartz 2D, the richness of these text layout engines would warrant an entire book in their own right.
The same QuickDraw library that was vital to the continued success of the Macintosh is still available on Mac OS X. QuickDraw includes the same drawing capabilities today that it has in the past. While Apple plans to maintain binary compatibility with applications that use QuickDraw, the library is now deprecated technology. Apple is no longer changing the QuickDraw code, and the library may become unavailable in future versions of the operating system.
This fact has a profound implication for developers who use the Carbon API. Their applications are probably using QuickDraw as their primary graphics library. If these applications are to grow with the system, developers will have to convert their drawing routines to use Quartz 2D or one of the other libraries in the Mac OS X graphics system.
The vImage library is part of the Accelerate framework and is another image processing library on the system. While the focus of Core Image is on visual image effects and transitions, vImage contains routines related to more scientific image processing tasks. Here are some of the features found in vImage:
- Conversion of image data between several different pixel types including conversion between planar and interleaved pixel formats.
- General Convolution on image data.
- Apply Fourier Transforms (one and two dimensional, real and complex valued) to a block of data. (The Fourier Transform is a mathematical operation that occurs often in image and signal processing).
- Apply "morphological" operations on data. Morphological operations manipulate images so that items pictured in the image change their shapes. Usually the items in the image will expand, shrink, or take on other aspects of a bitmap called the morphological kernel.
- Perform geometric operations on an image (such as scaling and resampling, rotations, and reflections).
- Generate histograms for the samples in an image. A histogram tells you how many of the pixels in an image are of a given intensity. Histograms play an important role, for example, in some image enhancement code.
- Alpha channel compositing. (Combining translucent and partially translucent images together)
Looking at this list, you may see many operations that are found in other graphics libraries in Mac OS X. Both Quartz 2D and QuickTime, for example, can be used to rotate an image or perform alpha channel compositing. vImage is a low-level library upon which some of those higher-level libraries are built. Because of this, using the routines in the vImage requires a bit more care on the part of the programmer. vImage can take advantage of multiple processors if they are available and use the SIMD units in those processors as well if they are available.
Mac OS X is an excellent platform for Java development. The Java system available on Mac OS X includes an impressive collection of technologies including the Java graphics library, Java 2D. Java 2D shares a large number of features with Quartz 2D. Both include graphics services for line art, text, and images and include support for alpha channel compositing. The two libraries have some abstractions in common, and many of the drawing techniques that are effective in one library have close analogs in the other library. With so many similarities, it should not surprise you to learn that the Java 2D implementation on Mac OS X relies on Quartz 2D for much of its functionality. In spite of the similarities in their feature sets, Quartz 2D and the Java 2D API use very different programming interfaces. Because it is a completely separate API, one that happens to be implemented using Quartz 2D, but which does not directly expose the functionality of that library, Java 2D is not explored in this book. However, there are a number of excellent resources available on the web and in books to help Java programmers get the most out of Java 2D.
This chapter has covered a lot of ground. Understanding where Quartz 2D fits into the graphics system, both historically and architecturally can help you make effective use of the system. Some time has been spent discussing other graphics technologies that may be of interest, and we encourage you to explore them at your leisure. Writing good graphics code on Mac OS X is often a question of finding the services on the system that most closely match your needs. Hopefully this brief discussion will help you find the services that benefit you.