Quartz 2D Graphics for Mac OS X Developers

Quartz 2D Graphics for Mac OS X Developers

by R. Scott Thompson
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


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

  • Forge connections between Quartz 2D and graphics devices using CGContexts
  • Simplify the drawing process using transformations
  • Draw line art using path-drawing operations on Bezier paths
  • Use pixel data to create images
  • Import and export images from Quartz 2D with Image I/O and QuickTime
  • Generate text and implement special text effects
  • Draw in offscreen environments, such as CGLayers and offscreen bitmaps
  • Create shadings and patterns
  • Create PDFs from Quartz 2D drawings or import PDFs into your drawings

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.

Product Details

Publication date:
Product dimensions:
6.90(w) x 9.00(h) x 0.80(d)

Read an Excerpt


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 QuickDraw—and 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.

© Copyright Pearson Education. All rights reserved.

Meet the Author

R. Scott Thompson is currently a software engineer at Mindjet Corporation (www.mindjet.com). He has been a professional Macintosh developer since 1993. Working with Apple as an independent consultant he helped developers move their applications from the classic Mac OS to Mac OS X. Prior to that, Scott was an engineer with Macromedia helping to create a popular PostScript-based print publishing application.

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >