Re: Converting colors to CGFloat
Re: Converting colors to CGFloat
- Subject: Re: Converting colors to CGFloat
- From: Steve Christensen <email@hidden>
- Date: Fri, 31 Jul 2009 08:44:10 -0700
On Jul 31, 2009, at 2:31 AM, Matthias Schmidt wrote:
how do I convert color values from longint or UInt16 as they were
used with the carbon API to CGFloat used with NSColor?
I assume you're talking about something like QuickDraw's RGBColor,
where color components range from 0 to 65535? You could do something
like this:
NSColor* NSColorFromQuickDrawRGBColor(const RGBColor* color)
{
return [NSColor colorWithCalibratedRed:((CGFloat)color->red /
65535.0)
green:((CGFloat)color->green /
65535.0)
blue:((CGFloat)color->blue /
65535.0)
alpha:1.0];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden