A Hands-On Guide and Introduction to Quartz 2D
On Mac OS X, Macintosh developers depend on the graphics and imaging frameworks of the Core Graphics system to implement multimedia features in their applications. With Core Graphics Apple has answered the increasing demands of graphics developers with a powerful collection of tools, including Quartz 2D and Core Image. Quartz 2D is a modern drawing API with a powerful imaging model. Beginning with Mac OS X 10.4, Tiger, Quartz 2D replaces the QuickDraw® graphics library in legacy applications and provides the functionality developers need to take advantage of the latest hardware.
Quartz 2D Graphics for Mac OS X® Developers is a hands-on guide and introduction to Quartz 2D. Differences between the interfaces and features of QuickDraw and Quartz 2D are making the switch challenging for developers. Through in-depth practical coverage, Mac developer and consultant Scott Thompson leads you smoothly through the transition and sets you on the path to developing cutting edge graphics in Core Image.
Through this invaluable guide, you will learn how to
If you depend on QuickDraw for your graphics needs, or are interested in a system that pushes the envelope in computer graphics, now is the time to make the switch to Core Graphics (Quartz 2D, Core Image). This is the book that walks you through that change–step-by-step!
The companion CD-ROM contains projects and source code covered in this book so you can run each sample. The samples demonstrate how to call Quartz 2D from both Carbon and Cocoa applications as well as from Mac OS X’s Python scripting interface.
Download the Sample
Chapter related to this title.
Chapter 1: Getting Started 1
Chapter 2: From QuickDraw to Quartz 2D 15
Chapter 3: Introduction to Quartz 2D 37
Chapter 4: The Graphics Context 69
Chapter 5: Transformations 103
Chapter 6: Line Art–Building Paths 135
Chapter 7: Line Art–Drawing 163
Chapter 8: Image Basics 177
Chapter 9: Importing and Exporting Images 211
Chapter 10: Drawing with Core Image 223
Chapter 11: Drawing Text with Quartz 2D 249
Chapter 12: Drawing Offscreen 265
Chapter 13: Shadings and Patterns 277
Chapter 14: Working with PDF 299
The graphics systems available to Macintosh applications have evolved very quickly over the past few years. Prior to the introduction of Mac OS X, the primary focus of all Macintosh graphics was the QuickDraw graphics library. QuickDraw not only provided the tools that applications needed to draw into their windows, but it also played a role in managing the screen, handling events, and changing the cursor. As the demands placed on the graphics system increased, Apple discovered that a reliance on QuickDraw imparted some limitations to their capability to expand the graphics system. During the transition to Mac OS X, many of QuickDraw's responsibilities migrated to other portions of the system. To handle many of the drawing and screen management tasks, Apple introduced a new graphics system called Quartz. In programming circles, Quartz is also known as Core Graphics.
Quartz not only handles many of the responsibilities of QuickDraw, it is the platform on which many of the innovations in the Mac OS X graphics system are built. For example, Core Graphics has taken over the job of collecting the images of windows and combing them on the screen. In performing this task, it takes advantage of modern graphics hardware to improve performance and introduce features such as translucent windows to the system. The end result is a remarkably flexible graphics system. Quartz allows applications to seamlessly integrate technologies as diverse as the motion graphics of QuickTime and the 3D graphics of OpenGL onto the same screen or even into the same window.
With the introduction of Mac OS X 10.4, Tiger, Apple has deprecated QuickDrawand that library will not evolve any farther. Applications that only rely on QuickDraw for drawing will not enjoy any innovations Apple makes in the graphics system. Even worse, in the future, applications that rely on QuickDraw may actually pay a performance penalty. Any program that wants to take full advantage of the graphics system on Mac OS X will have to replace their QuickDraw drawing code with a more modern alternative. Apple recommends that application developers replace their QuickDraw graphics code with similar code that uses Quartz 2D.
Quartz 2D is a part of the Core Graphics system. It is a modern graphics library based on the imaging model that Adobe created originally for PostScript printers and later as part of the PDF graphics file format. This is the same imaging model that graphics professionals have used for several years to create the artwork on everything from books and advertisements to application splash screens and on-line games.
The Quartz 2D drawing model allows you to create sophisticated graphics with a simple API. The Quartz 2D imaging model is quite different from the drawing models of other graphics libraries. Its library can draw to many kinds of graphics devices while maximizing the fidelity of the graphics on each device. As a result, developers familiar other graphics libraries such as QuickDraw, GDI from Microsoft Windows, or the graphics portions of X11's XLib face a learning curve when trying to work with the device and resolution independent drawing model in Quartz 2D.
The objective of this book is to present a practical introduction to Quartz 2D. Its aim is to help all programmers understand the Quartz 2D imaging model and make effective use of the library from any application environment. Most importantly, the text compares and contrasts the Quartz 2D imaging model with the pixel-based graphics models of other libraries. While this will be of particular value to developers making the transition from QuickDraw or GDI to Quartz 2D, it also provides valuable insight into how to use Quartz 2D effectively. The hope is that this information will be invaluable to anyone trying to draw graphics using Quartz 2D.