TweetFollow Us on Twitter

September 95 - Print Hints: Syncing Up With ColorSync 2.0

Print Hints: Syncing Up With ColorSync 2.0

David Hayward

In March of this year, Apple announced a major upgrade to the ColorSync extension and API: ColorSync 2.0. Like version 1.0, ColorSync 2.0 is a powerful color management system that allows applications and device drivers to produce consistent color across different devices. However, ColorSync 2.0 dramatically improves the quality, flexibility, and performance of color management. This column focuses on the new features of ColorSync 2.0 and how applications can take advantage of them. (For a good review of ColorSync 1.0 and color management in general, see John Wang's Print Hints column in develop Issue 14.)

WHAT IS COLORSYNC 2.0?

ColorSync 2.0 is an extension to the Mac OS that provides a color management system for applications, scanner drivers, printer drivers, and other components of the OS such as QuickDraw and QuickDraw GX. The objective of the color management system is to provide consistent color across devices that have different color ranges, or gamuts.
    All the versions of QuickDraw GX that have shipped as of this writing (v1.0.1 through v1.1.2) use the ColorSync 1.0 API. ColorSync 2.0 is backward compatible, so QuickDraw GX will work fine if ColorSync 2.0 is installed. QuickDraw GX version 1.2 will add full ColorSync 2.0 support.*
To understand the task of color management, consider the process of scanning, displaying, editing, and printing a color document: In a typical configuration, a color document may interact with three devices -- scanner, monitor, and printer -- each of which works with color in different ways. A scanner contains a CCD array, which is nonlinearly sensitive to specific frequencies of red, green, and blue light. A monitor hurls electrons at special phosphors to produce varying amounts of red, green, and blue light. And a color printer relies on a mixture of dyes, waxes, or toner to subtract cyan, magenta, yellow, and black from white paper. Because each of these devices uses different physical systems in different color spaces with different gamuts, providing consistent color is difficult. The goal is to provide the best consistency given the physical limitations of each device.

To meet this goal, ColorSync 2.0 requires detailed information about each device and how it represents or characterizes color. This information is encapsulated in a device profile. A ColorSync-savvy scanner stores (or "embeds") its profile in the document it creates. A ColorSync-savvy application uses the profile embedded in the document and displays it according to the monitor's profile; a ColorSync-savvy printer renders the document according to the printer's profile.

DEVICE PROFILES

Device profiles are the key ingredient of any color management system because they define the unique color behavior of each device. They're used by color management module (CMM) components, which perform the low-level calculations required to transform colors from a source device color space to a destination device color space.
    CMM used to stand for color matching method. There was disagreement with that name because a CMM component does a lot more than just color matching. So we changed the name to color management module to be more accurate.*
ICC profile format. ColorSync 2.0 uses a new profile format defined by the International Color Consortium (ICC), the founding members of which include Apple, Adobe Systems, Agfa-Gevaert, Eastman-Kodak, Microsoft, Silicon Graphics, Sun, and FOGRA (honorary). The International Color Consortium Profile Format Specification states the following in its introduction:

The intent of this format is to provide a cross-platform device profile format. Such device profiles can be used to translate color data created on one device into another device's native color space. The acceptance of this format by operating system vendors allows end users to transparently move profiles and images with embedded profiles between different operating systems. For example, this allows a printer manufacturer to create a single profile for multiple operating systems.

The ICC profile format is designed to be flexible and extensible so that it can be used on a wide variety of platforms and devices. The profile structure is defined as a header followed by a tag table followed by a series of tagged elements that can be accessed randomly and individually. In a valid profile, a minimal set of tags must be present, but optional and private tags may be added depending on implementation needs. Complete definitions of the required tags can be found in the profile format specification. Perhaps just as important, Apple and Adobe have defined how profiles can be embedded in the common graphics file formats PICT, EPS, and TIFF.

There have been changes in the way ColorSync works with profiles as a result of this new format. For example, with ColorSync 1.0, the entire profile format was compact enough to be used as a memory-based data structure, whereas with ColorSync 2.0, profiles can be much larger and typically are disk-based. However, ColorSync 2.0 can still make use of old 1.0 profiles for backward compatibility.

Profile types. There are three main types of device profile: input, display, and output. These types have the following signatures:

  • 'scnr' -- input devices such as scanners or digital cameras

  • 'mntr' -- display devices such as monitors or liquid crystal displays

  • 'prtr' -- output devices such as printers
In addition to these basic types, three other device profile types are defined:
  • 'link' -- Device link profiles concatenate into one profile a series of profiles that are commonly used together. A profile of this type can simplify and expedite the processing of batch files when the same combination of device profiles and non-device profiles is used repeatedly.

  • 'spac' -- Color space conversion profiles are used by CMMs to perform intermediate conversions between different device-independent color spaces.

  • 'abst' -- Abstract profiles provide a generic method for users to make subjective color changes to images or graphic objects by transforming the color data.

Profile quality and rendering intent. Typically you can think of a profile as a self-contained set of data that contains all the information needed for a CMM to perform a color match. Therefore, if an application wants to embed a profile in a document, it shouldn't have to make any changes to the profile -- the profile is just a black box of data. This is true for the most part, but there are a few attributes of a profile that an application can change to modify the behavior of the profile. So, it's better to conceptualize a profile as a black box of data with a few switches on the outside. Before embedding a profile in a document, an application can toggle any of these switches by setting the appropriate bit or bits in the profile's header. One of the switches determines the profile's quality and another specifies its rendering intent:

  • The quality flag bits provide a convenient place in the profile for an application to indicate the desired quality of a color match (potentially at the expense of speed and memory) as normal, draft, or best quality. In ColorSync 2.0 these qualities do not mandate the use of one algorithm over another; they're just "recommendations" that the CMM may choose to ignore or implement as it sees fit.

  • The rendering intent determines how the CMM performs the match. The possible intents are photographic matching, saturation matching, relative colormetric matching, and absolute colormetric matching.

Profile header structure: CMAppleProfileHeader. In the ColorSync 1.0 profile format, the first member of the profile header structure (CMAppleProfileHeader) is a CMHeader structure, which contains all the basic information about the profile. Similarly, the ColorSync 2.0 profile begins with a CM2Header structure. The fields of the CM2Header structure are slightly different from those in the old CMHeader, to reflect some of the improvements provided by the new ICC profile format. However, to be backward-compatible with 1.0, ColorSync 2.0 defines a union of the two header structures. Because the version field is at the same offset in both header structures, it can be used to determine the version of the profile format.

Because ColorSync 2.0 provides support for ColorSync 1.0 profiles, your application should be prepared to handle both formats. Your code should always check the version field of the header before accessing any of the other fields in the header or reading any of the profile's tags.

Profile location structure: CMProfileLocation. ColorSync 2.0 profiles are typically disk-based files, but they can also be memory-based handles or pointers. To allow this flexibility, whenever a profile location needs to be specified (as a parameter for CMOpenProfile, for example) a CMProfileLocation structure is used. This structure contains a type flag followed by a union of an FSSpec, a handle, and a pointer.

Profile reference structure: CMProfileRef. Once a profile has been opened, a private structure is created by ColorSync to maintain the profile until it's closed. A CMProfileRef (defined as a pointer to the private structure) can be used to refer to the profile.

COLOR WORLDS

A color world is a reference to a private ColorSync structure that represents a unique color-matching session. Although profiles can be large, a color world is a compact representation of the mapping needed to match between profiles. Conceptually, you can think of a color world as a sort of "matrix multiplication" of two or more profiles that distills all the information contained in the profiles into a fast multidimensional lookup table. A color world can be created explicitly with low-level routines such as NCWNewColorWorld or automatically with high-level routines like NCMBeginMatching.

COLORSYNC 2.0 ROUTINES

Here I'll briefly describe the most commonly used ColorSync 2.0 routines, grouped according to purpose.
    The API naming convention is as follows: Calls prefixed with "CM" are high-level color management routines, while those prefixed with "CW" are low-level routines that take a color world as an argument. An "N" before "CM" or "CW" indicates calls that are new to ColorSync 2.0, to distinguish them from the old ColorSync 1.0 calls (which are still supported for backward compatibility).*

Accessing profile files. There is a set of basic routines to work with profiles as a whole. For example, CMNewProfile, CMOpenProfile, CMCopyProfile, and CMGetSystemProfile do what you would expect from their names.

Accessing profile elements. These routines perform more specific operations on profiles and profile elements. CMValidate Profile checks whether a profile contains all the needed tags, CMGetProfileElement gets a specific tag type from a profile, and CMGetProfileHeader gets the important header information of a profile.

Embedding profiles. NCMUseProfile is a simple routine for embedding a profile into a PICT. If you need to extract a profile or embed a profile into a different file format, you can use CMFlattenProfile to embed or CMUnflattenProfile to extract.

QuickDraw-specific matching. These high-level routines provide a basic API to simplify color matching for QuickDraw drawing routines. NCMBeginMatching tells Color QuickDraw to begin matching for the current graphics device using the specified source and destination profiles. NCMUseProfileComment inserts a profile as a picture comment into an open picture. NCMDrawMatchedPicture draws a picture using color matching. CWMatchPixMap matches a PixMap using the specified color world.

Low-level matching. These low-level routines create color worlds and perform color matching. NCWNewColorWorld creates a color world using the specified source and destination profiles, while CWConcatColorWorld creates one using an array of two or more profiles. Using the specified color world, CWMatchColors matches a list of colors and CWMatchBitmap matches a generic bitmap.

Searching profile files. This set of routines allows your application to search the ColorSync(TM) Profiles folder for the subset of profiles that meets your needs. For example, you could search for only printer profiles and use the search result to provide a pop-up menu for the user. CMNewProfileSearch searches the ColorSync(TM) Profiles folder for all profile files that match the supplied CMSearchRecord. The matches aren't returned to the caller, but the number of profiles matched and a reference to the search result are returned. The search result is a CMProfileSearch structure that points to private structures maintained by ColorSync and can be accessed with a call like CMSearchGetIndProfile, which opens and returns a CMProfileRef for the nth member of the search result.

PostScript code generation. This set of routines allows your application or printer driver to generate PostScript(TM) code that can be sent to a PostScript Level 2 printer so that the actual matching calculations will be performed in the printer instead of on the user's computer. CMGetPS2ColorRendering gets a color rendering dictionary (CRD) for a specified source and destination profile. CMGetPS2ColorSpace gets a color space array (CSA) for a specified source profile.

BECOMING COLORSYNC-AWARE

At the very least, your application should respect any embedded profiles in the documents it works with. For example, if your application works with PICT files, it shouldn't do anything that would strip out the ColorSync picture comments used for embedding. Even though your application may choose not to make use of the profiles, another application or printer driver may be able to take advantage of them.

PRINTING WITH COLORSYNC

If your application prints QuickDraw data to a ColorSync-savvy printer driver, you need do nothing to get matched output. When the stream of QuickDraw data sent to the driver contains an embedded profile in picture comments, the ColorSync-savvy printer driver will create a new color world to match from the embedded profile to the printer's profile. The driver will then match subsequent QuickDraw operations accordingly before sending them to the printer. If the QuickDraw data stream doesn't contain embedded profiles, the driver will use the current system profile (the profile that the user selected in the ColorSync control panel) as the source profile. That way, the printed output will match the screen display.

One example of a ColorSync-savvy printer driver is the LaserWriter 8.3 driver. Whereas previous versions of LaserWriter 8 allowed the user to choose between "Black and White" and "Color/Grayscale" in the Print dialog, this version adds two new choices. "ColorSync Color Matching" tells the driver to use ColorSync to match an image on the host Macintosh before sending it to the printer. The other option, "PostScript Color Matching," instructs the driver to generate PostScript CSAs and CRDs, which are sent to the printer so that the actual matching is performed in the printer. (The ColorSync API is used to generate the CSAs and CRDs according to the source profiles that may be embedded in the document and the destination profile of the printer.) In either case, the LaserWriter 8.3 driver allows the user to choose a printer profile from a list of printer profiles installed in the ColorSync(TM) Profiles folder.

Because ColorSync-savvy printer drivers do much of the work for you, it's best if your application prints documents with QuickDraw even if they're not PICT files. For example, if your application reads and prints TIFF files, the best approach is to convert the TIFF data (which may have a profile embedded in tags) to a PicHandle (which would have the profile embedded in picture comments). To print, you draw the PicHandle with DrawPicture into the printer's color graphics port.

If the printer's driver doesn't support ColorSync, your application can still use ColorSync to produce matched output as long as you have an appropriate profile for the device. (There are several commercial tools that build ICC profiles.) Given a source and destination profile, you can use the ColorSync API to match the image or, if your application must send PostScript data directly to a printer, to generate CRDs.

WHAT ELSE A COLORSYNC-SAVVY APPLICATION CAN DO

There is much that an application can do with ColorSync that will help the user work with color. For starters, an application could do the following:
  • Provide the user with information on any profiles embedded in a document, and possibly also allow the user to change the quality and rendering intent settings of embedded profiles.

  • Include a print preview mode that shows a "soft proof" of the matched output on the display. The application accomplishes this by building a color world with CWConcatColorWorld that matches through three profiles: from the source profile (which is embedded in the document) to the printer's profile (which you allow the user to pick from a list of installed printer profiles) and back to the screen profile (which is the current system profile).

  • Along with soft-proofing, it's useful to show the user what colors in the document are out of gamut according to the current destination profile. Gamut checking can be done with routines such as CWCheckColors and CWCheckBitmap.
Note that the LaserWriter engineering team is designing new PrGeneral code for the 8.3.1 version of the driver. This will allow an application to determine what profile is selected in the Print dialog.

WHERE TO GO FOR MORE

Everything you need to use ColorSync 2.0, including interfaces, libraries, sample code, utilities, and the ICC profile format specification, is on this issue's CD and in the Mac OS Software Developer's Kit. The technical reference for ColorSync 2.0 consists of several chapters in the book Advanced Color Imaging on the Macintosh, which is also included on this issue's CD and will soon be available in print from Addison-Wesley; this documentation covers everything from a high-level discussion of color management theory to a detailed description of the ColorSync 2.0 API. Why not take a closer look and see how you can take of advantage of this new improved technology in your application?

DAVID HAYWARD (AppleLink HAYWARD.D) has been working in the Printing, Imaging, and Graphics group in Developer Technical Support for over a year. His proudest achievement to date is the ability to make his hour-long commute every morning without waking up until he hits the speed bumps on Apple's R&D campus. Currently Dave is developing a ColorSync CMM for his closet so that he no longer has to worry about mismatching his clothes.*

Thanks to Paul Danbold, Steve Swen, Nick Thompson, and John Wang for reviewing this column.*

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.