views:

130

answers:

2

With Snow Leopard the default gamma changed from 1.8 to 2.2. I happen to be working on a few Mac apps that use a very dark custom colour scheme provided by Cocoa. On 10.5 it looks fine but on 10.6 with the new gamma it's much darker and really hard on the eyes.

The colour scheme is defined using numerous [NSColor colorWithCalibratedRed:green:blue:alpha:] objects within a theme class.

Is there any way to 'convert' an NSColor object so that it displays on 10.6 exactly as it would on 10.5?

I know this can be achieved globally from within System Preferences but that's not what I'm after.

A: 

The best thing to do is store the color profile for the display on which the color looked good.

Then, use the color profile for the display currently in use to to covert the color.

Basically, what you will have is:

(Original Color with Original Profile) converted to (New Color with current color profile).

You will always have three of the four items - you just need to compute the New Color.

For more information, I would suggest reading:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/DrawColor/DrawColor.html

ericgorr
Thanks, I need access to the red, green, blue and alpha colour components. As far as I can see only NSColor objects created with colorWithCalibratedRed:.. and colorWithDeviceRed:.. give you that freedom.
Stephen Blinkhorn
Actually, no. Once to really get into all of the details, you can do whatever you like. Although, at times you need to realize, for example, that a RGB color might represent multiple CMYK colors...
ericgorr
A: 

The only real problems I have are with dark coloured gradients. 10.4 is still a valid target so I have been using my own gradient wrapper class based around CGShading objects for some time (NSGradient is 10.5+ only).

A simple non-linear correction curve based on the formula below can help:

colour_component = pow(colour_component, 1.0/1.19);

The 1.19 value can be adjusted to create different correction curves.

If 10.6 is detected at run time (using Gestalt) the curve is applied to each of the red, green and blue components for both start and end colours before the gradient is calculated. I have left the alpha values untouched.

I also added a handy user preference to turn this on and off.

Stephen Blinkhorn