TweetFollow Us on Twitter

Jun 01 ADC Direct

Volume Number: 17 (2001)
Issue Number: 06
Column Tag: ADC Direct

Beyond QuickDraw: Quartz

by Travis W. Brown

A Brief Introduction to Mac OS X's New Imaging Model

For nearly two decades, Macintosh graphics have revolved around QuickDraw. QuickDraw was revolutionary, offering a unified imaging model that could be used for application drawing, printing, and providing a platform-wide graphics format. Unfortunately, today's applications frequently require graphic fun-ctionality that exceeds QuickDraw's reach. Developers frequently have to work around issues such as the lack of spline-based curves and text rotations. With the introduction of Mac OS X, a revolution-ary new imaging model—Quartz—is ready to meet the needs of cur-rent and future applications.

This article is a brief introduction to Quartz and will focus on its architecture and functionality. Where appropriate, this article will also call out various technical resources that will help you take advantage of what Quartz has to offer.

What is Quartz?

Quartz is a set of powerful graphics services that form the graphics component of Mac OS X's application services layer. In this role, Quartz pro-vides the rest of the system with a powerful 2-D render-ing engine that supports advanced vector graphics (complete with anti-aliasing and transparency support.) Quartz also implements the windowing system for Mac OS X and provides low-level services such as system-wide event handling. Quartz plays a key role in Mac OS X's printing architec-ture as well and provides rasterization and conversion services for print jobs.

The Quartz Architecture

As noted in Inside Mac OS X: System Overview, Quartz is actually composed of two separate parts that perform different functions: Quartz Compositor and Quartz 2D.

Quartz Compositor

The Quartz Compositor (formerly Core Graphics Services) is responsi-ble for providing windowing services for the Classic, Carbon, Cocoa, and Java application environments. These environments interact directly with the Quartz Compositor to automatically bring advanced windowing features, such as double-buffering and live window drag-ging, to applications. OpenGL and QuickTime rely on the Quartz Compositor to seamlessly mix hardware accelerated 3-D and multime-dia into a single visually consistent windowing environment. Finally, the Quartz Compositor helps create the hallmark Aqua user experi-ence by generating dynamic drop shadows and transparency effects for each open window.

Quartz 2D

Quartz 2D (formerly Core Graphics Rendering) is a two-dimen-sional graphics engine that allows any Mac OS X application to create graphics that were previously limited to high-end applica-tions. Quartz is based on the Portable Document Format (PDF) graphics model and features a rich set of drawing functions. These drawing functions are fully accessible by both Carbon and Cocoa developers.

Core Graphics API Functionality in Quartz 2D

The full power of the Quartz 2D engine is exposed through the Core Graphics API. What follows is a breakdown of the advanced features you can use to create new and exciting Mac OS X applications.

Drawing Functionality

The Core Graphics API contains a comprehensive set of functions that give you access to PostScript-like drawing features. Some of these features include path-based drawing operations (such as

Beziér curves), clipping paths, and transformable coordinate spaces that allow easy access to rotations, scales, and skews. The Quartz 2D engine draws using an advanced sub-pixel anti-aliasing algorithm that significantly enhances the visual appeal of both vectors and text. Additionally, Quart 2D's alpha compositing ability allows for trans-parency effects for vector shapes and supports alpha channels when drawing bitmaps. Detailed information on the Core Graphics API can be found in Inside Mac OS X: Drawing With Quartz, available from the Apple Developer Connection web site at:
http://developer.apple.com/quartz

PDF Support

The Quartz 2D engine is based on the PDF specification and is therefore able to parse and render most PDF files. Using the Core Graphics API, it is easy to add the ability to display PDF files to your application. This PDF support also allows applications to create PDF files by redirecting drawing calls into a file. The resultant PDF file can contain all types of graphic content, including fonts, text, vec-tors, and bitmaps. These capabilities make the PDF file an excellent replacement for the well-worn PICT file.

Adobe's Portable Document Format, v1.3 Reference Guide is the authoritative source of information on the PDF format. The "Graphics" section of the reference guide is particularly useful for understanding the PDF drawing model upon which Quartz 2D is based. You can find the complete guide at:
http://partners.adobe.com/asn/developer/acrosdk/docs/PDFRef.pdf

Color Management

The Quartz 2D engine works in concert with ColorSync to ensure everything it draws is color managed. This tight integration allows your application to participate in end-to-end color management with minimal effort on your part. At the most basic level, your application can programmatically specify colors in a variety of color spaces via the Core Graphics API. Quartz 2D will automati- cally call on ColorSync to ensure the requested color is matched to the display or printer. Color management is also automatically used when drawing PDFs and bitmap images. Lastly, the Quartz 2D engine also has full support for ICC color profiles and render-ing intents.

More information on color management and ColorSync can be found at:
http://developer.apple.com/techpubs/macos8/MultimediaGraphics/ColorSyncManager/colorsyncmanager.html

Fidelity

The Quartz 2D engine is resolution independent and is capable of rendering graphics for both screen and print. The Quartz 2D engine plays an important role in Mac OS X's printing architecture where it acts as the Raster Image Processor (RIP) for inkjet printers and other raster devices. The Quartz 2D engine is also capable of converting graphic streams into PostScript code for imaging on PostScript output devices. So, applications that use the Core Graphics API can easily output graphics to a full range of printers, from inexpensive inkjet printers to high-end PostScript devices, with excellent and consistent results.

Resources to Help You Take Full Advantage of Quartz

The Quartz technologies web site is the first place you should check for the latest information on Mac OS X's graphic technologies. The Quartz web site, which is part of the Apple Developer Connection, can be found at:
http://developer.apple.com/quartz/index.html

For compatibility with earlier versions of the Mac OS, Carbon applications use QuickDraw for two-dimensional graphics drawing by default. These applications can, however, access Quartz 2D's Core Graphics API. The Quartz Primer was created to help Carbon developers understand how to use this powerful tool. The primer is available at:
http://developer.apple.com/techpubs/macosx/SystemOverview/devessentials.html

Many Carbon developers have expressed interest in drawing text using Quartz 2D's advanced anti-aliasing. The Core Graphics API has basic support for text drawing, though. Higher-level services, such as ATSUI and MLTE, have been included in Mac OS X to draw text when working with Quartz. More information on Mac OS X's text services can be found at:
http://developer.apple.com/intl/index.html

Cocoa developers have a "free pass" to access the Quartz 2D engine. Three key classes–NSView, NSImage, and NSBezierPath– call through to the Quartz 2D engine. Developers may discover cases, though, in which directly accessing the Quartz 2D engine is desirable. To address this need, the Core Graphics API can easily be called from Cocoa and used in conjunction with a Cocoa View. Information contained within the Core Graphics header files is a good place to start. The header files can be found at:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/ Headers

Other Quartz APIs of Interest

In addition to the Core Graphics API, Quartz also contains some specialized APIs that may be of inter-est to you.

Remote Operation

This API interacts with Quartz Compositor to enable applications to capture screen contents and push keyboard/mouse events into the system. If you are designing a screen capture program, a remote access application, or an accessibility aid then you should check out the CGRemoteOperation API. A well-documented header file is located at:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/ Headers/CGRemoteOperation.h

Direct Display

This API allows applications to get direct access to the screen. Applications, such as games, can use this API to capture the display, set the display reso-lution, and gain direct access to the frame buffer. Information on CGDirectDisplay can be found in the header file that is located at:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/ Headers/CGDirectDisplay.h

Summary

Quartz is a powerful new graphics system that performs two vital roles in Mac OS X. The Quartz Compositor provides windowing services to all of Mac OS X. The Quartz 2D engine is responsible for creating visually rich graphic content on-screen and ensuring high-fidelity output to all classes of printers. Of primary interest to develop-ers is the Core Graphics API. This API offers devel-opers exciting opportunities to create new and powerful graphic applications by leveraging the Quartz 2D engine's PostScript-style drawing, color management, and PDF file support.


Project Builder Tips and Tricks

  • The malloc library on Mac OS X has a bunch of features that can help you track down memory smashers, buffer overruns, and other Stupid Pointer Tricks(tm). Check out
    /Developer/Documentation/ReleaseNotes/ MallocOptions.html to learn how to use these features.
  • Don't put all your application's user interface into one nib. When a nib file is open all objects are instantiated at once. Breaking up your user interface among multiple nibs will make your application launch faster and use less memory. It will also be easier to reuse part of your application.
  • Interface Builder
    Option Drag knobs: Makes matrices in Cocoa
    Command: Inverts guide activation
    Double Click to open editors
    Shift-arrow: nudge widgets by 10 instead of 1 pixels
    Drag custom views into the document for use as accessory views
    Option drag views into New Palettes

New Mac OS X Related Releases

  • Mac OS X 10.0.2 and iTunes 1.1.1
    Mac OS X 10.0.2 and iTunes 1.1.1 together add the ability to burn custom music CDs to Macintosh computers with CD-R drives. Mac OS X also features improvements in overall application stability and the latest version of the Internet file transfer service (ftpd), which features important security improvements.
    http://asu.info.apple.com/swupdates.nsf/artnum/n12181/
    http://asu.info.apple.com/swupdates.nsf/artnum/n12186/
  • CarbonLib 1.3.1 SDK
    The CarbonLib 1.3.1 SDK (Software Development Kit) for Mac OS X is now available to all developers. This SDK provides all the files needed to begin Carbon development. Contact Software Licensing to distribute CarbonLib 1.3.1 with your product.
    http://developer.apple.com/sdk/
  • Disk First Aid 8.6.1 (US and Int'l English)
    Disk First Aid 8.6.1 (US and Int'l English) is a utility that verifies and repairs some problems that may occur on Mac OS Extended format hard disk drives. This version of repairs certain types of master directory block damage on Mac OS Extended format volumes. It also improves the compatibility of Mac OS Extended format hard disks with Mac OS X.
    http://asu.info.apple.com/swupdates.nsf/artnum/n12187/
  • Software Update 1.3.1
    Software Update 1.3.1 is a multicountry update for the Mac OS X Software Update control panel.
    http://asu.info.apple.com/swupdates.nsf/artnum/n12165/
  • Darwin 1.3.1
    Darwin 1.3.1 is the open source core of Mac OS X. This open source project allows developers to customize and enhance key Apple software. The Darwin kernel is based on FreeBSD and Mach 3.0 technologies and provides protected memory and pre-emptive multitasking.
    http://www.opensource.apple.com/projects/darwin/

    Developer Documentation

    The following new and updated documentation is available to help with successful Mac OS X application and peripheral development at:
    http://developer.apple.com/techpubs/

    iBook Developer Note


    TN2018 - Importing animated GIFs
    TN2017 - Using Launch Services for discovering document binding and launching applications
    QA1034 - How to define a plst resource in a .r file
    QA1033 - Targeting DebuggingCarbonLib asserts
    QA1032 - Late breaking news for the MacsBug gdb plugin
    QA1031 - OpenGL Texture Sharing Between Contexts
    QA1030 - Getting NSWindow's toolbar actions to show up in Interface Builder
    QA1029 - How to get custom views to show up in NSToolbarItems
    QA1028 - ICLaunchURL, "file:///" URLs and Mac OS X
    QA1027 - Improving ATSUI text drawing performance
    QA1026 - Calling AppleScript from an Application
    QA1023 - The installer turns my application into a folder
    QA1022 - Where should I install my help book, and how does Help Viewer locate it?
    QA1021 - Cocoa-Java quit/cancel-quit header bug in Mac OS X 10.0
    QA1015 - Why am I drawing directly to the screen?
    QA1011 - How do I use QuickDraw with CGDirectDisplay?
    QA1010 - SynCGContextOriginWithPort
    QA1009 - Why are my Core Graphics calls drawing updside down?---

    Sample Code - More than thirty new Mac OS X code samples were posted to the ADC web site since the last issue. Please visit the URL below for a complete list of sample code.
    http://developer.apple.com/samplecode/


Did You Know?

Quartz Documentation

The technical writers at Apple are hard at work preparing Quartz documentation for software developers. Already available is the "Quartz Primer," a short document that summarizes Quartz features and concepts, discusses how to incorporate the graphics-rendering capabilities of Quartz into Carbon code, and includes examples of using Quartz APIs. You can get this document at
http://developer.apple.com/techpubs/macosx/SystemOverview/devessentials.html

In the works is Inside Mac OS X: Drawing With Quartz. This book is intended to be an essential resource for any software developer interested in learning about and using the advanced two-dimensional graphics capabilities of Mac OS X. It will discuss the following topics:

  • graphics contexts, coordinates, transformation matrices, graphics state, and transfer modes
  • transparency and anti-aliased drawing
  • drawing shapes with paths
  • drawing text
  • working with color
  • drawing images and PDF documents

Upcoming Seminars and Events

For more information on Apple developer events please visit the developer Events page at:
http://developer.apple.com/events/

Training and Seminars

R/com Offers Mac OS X Developer Training Online
R/com, also known as Media School, has partnered with Apple Developer Connection to create online training for Mac OS X developers. The first cours-es include "Application Development for Mac OS X," "Carbon Development for Mac OS X," and "Cocoa: The Object-Oriented Application Solution." Check out to take a free virtual seminar, learn more about current and upcoming courses, and find out about the significant discounts offered to Premier, Select, and student members of the Apple Developer Connection.
http://www.mediaschool.com/adc

Apple iServices 5-day Cocoa Training
For application developers who want to learn how to develop Mac OS X applications using Cocoa, Apple iServices offers a five-day comprehensive, hands-on Cocoa training course. This course uses real-world examples and is perfect for developers who have a general understanding of object-oriented concepts and practical experience with the C programming language or a C-derived language (Object-C, Java, or C++). The course costs US $2,495
http://www.apple.com/iservices/technicaltraining/cocoadev.html

AppleScript Intensive Workshop
Four-day interactive experience for intermediate and advanced scripters June 4-7 in Chicago IL (DATES CHANGED) June 12-15 in Santa Monica CA
http://www.mainevent.com/intensive.html

Developer Related Conferences


QuickTime BootCamp Authoring Conference in Europe
Held June 6 and 7 in Cologne, Germany
http://www.qtbootcamp.de

MacHack Conference Dearborn, MI
June 21-23
MacHack, in its sixteenth year, remains centered around cutting edge soft- ware development. MacHack's uniqueness derives from the informal feel and the LIVE coding that occurs around-the-clock during the conference.
http://www.machack.com/

MACWORLD Expo, New York 2001
July 17-20 in Jacob Javits Convention Center, NYC
Discounted exhibitor packages available
http://developer.apple.com/mkt/mwny2001.html


Travis W. Brown is the Imaging Technology Manager for Mac OS X in Apple's Worldwide Developer Relations. Travis has been involved in digital imaging for the past decade, working on various products, ranging from drivers for color printers and digital photographic imaging systems to PostScript interpreters.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

coconutBattery 3.9.14 - Displays info ab...
With coconutBattery you're always aware of your current battery health. It shows you live information about your battery such as how often it was charged and how is the current maximum capacity in... Read more
Keynote 13.2 - Apple's presentation...
Easily create gorgeous presentations with the all-new Keynote, featuring powerful yet easy-to-use tools and dazzling effects that will make you a very hard act to follow. The Theme Chooser lets you... Read more
Apple Pages 13.2 - Apple's word pro...
Apple Pages is a powerful word processor that gives you everything you need to create documents that look beautiful. And read beautifully. It lets you work seamlessly between Mac and iOS devices, and... Read more
Numbers 13.2 - Apple's spreadsheet...
With Apple Numbers, sophisticated spreadsheets are just the start. The whole sheet is your canvas. Just add dramatic interactive charts, tables, and images that paint a revealing picture of your data... Read more
Ableton Live 11.3.11 - Record music usin...
Ableton Live lets you create and record music on your Mac. Use digital instruments, pre-recorded sounds, and sampled loops to arrange, produce, and perform your music like never before. Ableton Live... Read more
Affinity Photo 2.2.0 - Digital editing f...
Affinity Photo - redefines the boundaries for professional photo editing software for the Mac. With a meticulous focus on workflow it offers sophisticated tools for enhancing, editing and retouching... Read more
SpamSieve 3.0 - Robust spam filter for m...
SpamSieve is a robust spam filter for major email clients that uses powerful Bayesian spam filtering. SpamSieve understands what your spam looks like in order to block it all, but also learns what... Read more
WhatsApp 2.2338.12 - Desktop client for...
WhatsApp is the desktop client for WhatsApp Messenger, a cross-platform mobile messaging app which allows you to exchange messages without having to pay for SMS. WhatsApp Messenger is available for... Read more
Fantastical 3.8.2 - Create calendar even...
Fantastical is the Mac calendar you'll actually enjoy using. Creating an event with Fantastical is quick, easy, and fun: Open Fantastical with a single click or keystroke Type in your event details... Read more
iShowU Instant 1.4.14 - Full-featured sc...
iShowU Instant gives you real-time screen recording like you've never seen before! It is the fastest, most feature-filled real-time screen capture tool from shinywhitebox yet. All of the features you... Read more

Latest Forum Discussions

See All

The iPhone 15 Episode – The TouchArcade...
After a 3 week hiatus The TouchArcade Show returns with another action-packed episode! Well, maybe not so much “action-packed" as it is “packed with talk about the iPhone 15 Pro". Eli, being in a time zone 3 hours ahead of me, as well as being smart... | Read more »
TouchArcade Game of the Week: ‘DERE Veng...
Developer Appsir Games have been putting out genre-defying titles on mobile (and other platforms) for a number of years now, and this week marks the release of their magnum opus DERE Vengeance which has been many years in the making. In fact, if the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 22nd, 2023. I’ve had a good night’s sleep, and though my body aches down to the last bit of sinew and meat, I’m at least thinking straight again. We’ve got a lot to look at... | Read more »
TGS 2023: Level-5 Celebrates 25 Years Wi...
Back when I first started covering the Tokyo Game Show for TouchArcade, prolific RPG producer Level-5 could always be counted on for a fairly big booth with a blend of mobile and console games on offer. At recent shows, the company’s presence has... | Read more »
TGS 2023: ‘Final Fantasy’ & ‘Dragon...
Square Enix usually has one of the bigger, more attention-grabbing booths at the Tokyo Game Show, and this year was no different in that sense. The line-ups to play pretty much anything there were among the lengthiest of the show, and there were... | Read more »
Valve Says To Not Expect a Faster Steam...
With the big 20% off discount for the Steam Deck available to celebrate Steam’s 20th anniversary, Valve had a good presence at TGS 2023 with interviews and more. | Read more »
‘Honkai Impact 3rd Part 2’ Revealed at T...
At TGS 2023, HoYoverse had a big presence with new trailers for the usual suspects, but I didn’t expect a big announcement for Honkai Impact 3rd (Free). | Read more »
‘Junkworld’ Is Out Now As This Week’s Ne...
Epic post-apocalyptic tower-defense experience Junkworld () from Ironhide Games is out now on Apple Arcade worldwide. We’ve been covering it for a while now, and even through its soft launches before, but it has returned as an Apple Arcade... | Read more »
Motorsport legends NASCAR announce an up...
NASCAR often gets a bad reputation outside of America, but there is a certain charm to it with its close side-by-side action and its focus on pure speed, but it never managed to really massively break out internationally. Now, there's a chance... | Read more »
Skullgirls Mobile Version 6.0 Update Rel...
I’ve been covering Marie’s upcoming release from Hidden Variable in Skullgirls Mobile (Free) for a while now across the announcement, gameplay | Read more »

Price Scanner via MacPrices.net

New low price: 13″ M2 MacBook Pro for $1049,...
Amazon has the Space Gray 13″ MacBook Pro with an Apple M2 CPU and 256GB of storage in stock and on sale today for $250 off MSRP. Their price is the lowest we’ve seen for this configuration from any... Read more
Apple AirPods 2 with USB-C now in stock and o...
Amazon has Apple’s 2023 AirPods Pro with USB-C now in stock and on sale for $199.99 including free shipping. Their price is $50 off MSRP, and it’s currently the lowest price available for new AirPods... Read more
New low prices: Apple’s 15″ M2 MacBook Airs w...
Amazon has 15″ MacBook Airs with M2 CPUs and 512GB of storage in stock and on sale for $1249 shipped. That’s $250 off Apple’s MSRP, and it’s the lowest price available for these M2-powered MacBook... Read more
New low price: Clearance 16″ Apple MacBook Pr...
B&H Photo has clearance 16″ M1 Max MacBook Pros, 10-core CPU/32-core GPU/1TB SSD/Space Gray or Silver, in stock today for $2399 including free 1-2 day delivery to most US addresses. Their price... Read more
Switch to Red Pocket Mobile and get a new iPh...
Red Pocket Mobile has new Apple iPhone 15 and 15 Pro models on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide service using all the major... Read more
Apple continues to offer a $350 discount on 2...
Apple has Studio Display models available in their Certified Refurbished store for up to $350 off MSRP. Each display comes with Apple’s one-year warranty, with new glass and a case, and ships free.... Read more
Apple’s 16-inch MacBook Pros with M2 Pro CPUs...
Amazon is offering a $250 discount on new Apple 16-inch M2 Pro MacBook Pros for a limited time. Their prices are currently the lowest available for these models from any Apple retailer: – 16″ MacBook... Read more
Closeout Sale: Apple Watch Ultra with Green A...
Adorama haș the Apple Watch Ultra with a Green Alpine Loop on clearance sale for $699 including free shipping. Their price is $100 off original MSRP, and it’s the lowest price we’ve seen for an Apple... Read more
Use this promo code at Verizon to take $150 o...
Verizon is offering a $150 discount on cellular-capable Apple Watch Series 9 and Ultra 2 models for a limited time. Use code WATCH150 at checkout to take advantage of this offer. The fine print: “Up... Read more
New low price: Apple’s 10th generation iPads...
B&H Photo has the 10th generation 64GB WiFi iPad (Blue and Silver colors) in stock and on sale for $379 for a limited time. B&H’s price is $70 off Apple’s MSRP, and it’s the lowest price... Read more

Jobs Board

Optometrist- *Apple* Valley, CA- Target Opt...
Optometrist- Apple Valley, CA- Target Optical Date: Sep 23, 2023 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 796045 At Target Read more
Senior *Apple* iOS CNO Developer (Onsite) -...
…Offense and Defense Experts (CODEX) is in need of smart, motivated and self-driven Apple iOS CNO Developers to join our team to solve real-time cyber challenges. Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Child Care Teacher - Glenda Drive/ *Apple* V...
Child Care Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Share on Facebook Apply Read more
Machine Operator 4 - *Apple* 2nd Shift - Bon...
Machine Operator 4 - Apple 2nd ShiftApply now " Apply now + Start apply with LinkedIn + Apply Now Start + Please wait Date:Sep 22, 2023 Location: Swedesboro, NJ, US, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.