Cocoa, Quartz, Colorspaces and ColorSync
Cocoa, Quartz, Colorspaces and ColorSync
- Subject: Cocoa, Quartz, Colorspaces and ColorSync
- From: Robert Clair <email@hidden>
- Date: Wed, 29 Sep 2004 11:47:08 -0400
Apologies in advance for the multiple post, but the subject spans
several areas and information is scarce.
I'm writing a Cocoa graphic arts app and I'm trying to make it at least
minimally color managed. (Or, at least, I'm trying to write it so that
adding full color management later doesn't require a complete rewrite.)
I've searched the docs, the web and the archives and I haven't found
much in the way of information. The docs are outdated - the section of
the ColorSync documentation titled "Developing Your
ColorSync-Supportive Application" is written in terms of QuickDraw and
PICT images. I understand in principle how color management works, it
is just the specifics and detailed information on what is really
happening that are missing.
For the moment I'm not concerned about reading in files or images with
embedded profiles, just with things that I'm creating in Cocoa. I'm not
sure what the definition of "device indenpendence" is here. Presently
when my app saves a file (in its own file format) the colors are saved
by archiving the NSColor objects that were created as "device
independent" colors. If I then open the file on a system with a
different display is the color on the new screen a ColorSync match for
the color on the screen of the first system ? Or should I get the
components from the NSColor object, store them and use them to
initialize a new NSColor object when opening the file?
The NSColor class method colorWithCalibratedRed:green:blue:alpha:
supposedly returns a calibrated or "device independent" color in the
NSCalibratedRGBColorSpace. I take this to mean that the "working space"
of a Cocoa program using calibrated RGB is NSCalibratedRGBColorSpace.
WHAT SPACE IS THIS ???? If it is a real color space, it should have a
defined relationship to, say, CIE XYZ. Is it the spaced defined by the
profile "Generic RGB Profile" ? (This would be at least consistent,
because that's what the Cocoa printing system is putting in the spool
pdf.) Is it always the same or does it depend on what is set as the
default RGB profile ?
By way of contrast, in CoreGraphics you must first set the colorspace
and then the color before you draw. The Quartz function to obtain a
Calibrated RGB space, CGColorSpaceCreateCalibratedRGB, requires that
you specify a white point, a black point, gammas and a matrix - all the
info needed to relate the space to CIE 1931 XYZ. Or
you can use CGColorSpaceCreateICCBased with a specific profile.
My first guess was that code like
NSColor* myCalibratedColor =
[NSColor colorWithCalibratedRed: myRed green: myGreen blue:
myBlue alpha: 1.0];
[myCalibratedColor set];
was just sugar coating for something like this:
CGColorspaceRef myColorSpaceRef =
CGColorSpaceCreateCalibratedRGB( myWhitePoint, myBlackPoint,
myGammas, myMatrix);
or
CGColorspaceRef myColorSpaceRef =
CGColorSpaceCreateICCBased ( 3, myRangeArray, myProfileProviderRef,
myAlternatespaceRef );
followed by
CGContextSetFillColorSpace( myContextRef, myColorSpaceRef );
CGContextSetStrokeColorSpace( myContextRef, myColorSpaceRef );
CGContextSetFillColor( myContextRef, myComponentArray);
CGContextSetStrokeColor( myContextRef, myComponentArray);
for some default data or profile. Then life would be (relatively)
simple if someone could tell
me what space the default data corresponds to.
Stepping with the debugger, this seems not to be the case. NSColor is
apparently a class cluster and the code creates an instance of a
NSCaliabratedRGB color. Since this is internal there is no information
available. So, again, the plea: what is happening under the hood here ?
Also: what is ColorSync really doing here when things are drawn to the
screen ?? I supply an RGB to to Cocoa via [NSColor
colorWithCalibratedRed:green:blue:alpha:], set that color, draw, and
some (other) RGB is applied by the graphics card to the inputs of the
display. Where and when do the various transformations take place ?
A related question: What exactly is the Digital Color Meter app
measuring for RGB ?? It is clearly getting
an RGB somewhere before the display correction is applied - the numbers
it reports are the same for a given thing on the screen even when the
display profile is changed to wildly different things.
Any information, confirmations or pointers to reliable information
would be greatly appreciated.
Bob Clair
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden