CGColorRef to NSColor?
CGColorRef to NSColor?
- Subject: CGColorRef to NSColor?
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 20 Dec 2004 06:17:24 -0500
I am able to convert a CGColorRef (Core Graphics) to an NSColor (Cocoa).
However, I am ignoring the CGColorRef's color space, because I don't know
how to find out what it is in a way that will enable me to set the same
color space in the NSColor object. I just assume calibrated RGB, because
this is only for display on monitors, not printing, but I don't know enough
about the subject to know whether this might get me into trouble.
How do I get the CGColorRef's color space (in an inexpensive way), such that
I can use the information to set the color space to match in the new
NSColor?
Here's my current conversion code:
CGColorRef inColor = (CGColorRef)<never mind where I get the CGColorRef>;
float *colorComponents = (float *)CGColorGetComponents(inColor);
NSColor *outColor = [NSColor colorWithCalibratedRed:colorComponents[0]
Green: colorComponents[1] Blue: colorComponents[2] Alpha:
colorComponents[3]];
I can do this to get the CGColorSpaceRef:
CGColorSpaceRef colorSpace = CGColorGetColorSpace(inColor);
But I don't know how to use it to get the color space name that is
apparently required to set the correct color space in the Cocoa NSColor (at
least in Panther).
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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