Re: NSColor to CGColor
Re: NSColor to CGColor
- Subject: Re: NSColor to CGColor
- From: Antonio Nunes <email@hidden>
- Date: Sun, 12 Nov 2006 17:56:21 +0000
On 12 Nov 2006, at 15:48, j o a r wrote:
I also bumped into this problem recently and ended up implementing
this function:
static CGColorRef CGColorCreateFromNSColor (CGColorSpaceRef
colorSpace, NSColor *color)
{
NSColor *deviceColor = [color colorUsingColorSpaceName:
NSDeviceRGBColorSpace];
float components[4];
[deviceColor getRed: &components[0] green: &components[1] blue:
&components[2] alpha: &components[3]];
return CGColorCreate (colorSpace, components);
}
That I call like this:
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB ();
CGColorRef cgColor = CGColorCreateFromNSColor (colorSpace, nsColor);
CGColorSpaceRelease (colorSpace);
// Do stuff with cgColor
CGColorRelease (cgColor);
Thanks Joar (and Daniel),
The above should do just fine for my purposes. I had a feeling it
might be something of the sort, but wanted to make sure I wasn't
overlooking anything.
Cheers,
António
-----------------------------------------------------------
And could you keep your heart in wonder
at the daily miracles of your life,
your pain would not seem less wondrous
than your joy.
--Kahlil Gibran
-----------------------------------------------------------
_______________________________________________
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