• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting colors to CGFloat
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting colors to CGFloat


  • Subject: Re: Converting colors to CGFloat
  • From: Jesper Storm Bache <email@hidden>
  • Date: Fri, 31 Jul 2009 08:52:38 -0700

Given that QD is not color managed, I would expect that you should use [NSColor colorWithDeviceRed..] rather than the calibrated variation.
(I must admit that I find the documentation regarding calibrated and device rather thin in various NSColor references).


Jesper

On Jul 31, 2009, at 8:44 AM, Steve Christensen wrote:

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

_______________________________________________

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


References: 
 >Converting colors to CGFloat (From: Matthias Schmidt <email@hidden>)
 >Re: Converting colors to CGFloat (From: Steve Christensen <email@hidden>)

  • Prev by Date: Re: Converting colors to CGFloat
  • Next by Date: Re: Exception-like behavior in save panel used for file choose
  • Previous by thread: Re: Converting colors to CGFloat
  • Next by thread: Application Preferences - a general question
  • Index(es):
    • Date
    • Thread