开发者

NSColor, 10.6 and Gamma 2.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 开发者_StackOverflow社区that's not what I'm after.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜