Re: NSColor (RGB) from Lab values?
Re: NSColor (RGB) from Lab values?
- Subject: Re: NSColor (RGB) from Lab values?
- From: Glenn Andreas <email@hidden>
- Date: Thu, 17 Jun 2004 13:33:34 -0500
At 6:13 PM +0200 6/17/04, b UND d wrote:
I want to have colors with given Lab values correctly displayed (=
converted to RGB NSColors).
As far as i know NSColor does not support Lab color space. Is there
a convenient way to convert the Lab values to RGB?
I thought of ColorSync but i found only 'CMConvertLabToXYZ' and no
way further to RGB.
I found some math for converting Lab -> XYZ -> RGB at
www.easyRGB.com - but the results of this formula slightly differ
from what PhotoShop sais (all calculated colors are too bright).
Many thanks in advance for any help
Dominik
Typed in mail, no error checking:
CMProfileRef srcProfile, dstProfile;
CMGetDefaultProfileBySpace(cmLabData,&srcProfile);
CMGetDefaultProfileBySpace(cmRGBData,&dstProfile);
CMWorldRef colorWorld;
NCWNewColorWorld(&colorWorld, srcProfile, dstProfile);
CMColor color;
color.Lab = srcRGBColor;
CWMatchColors(colorWorld, &color, 1);
CWDisposeColorWorld(colorWorld);
CMCloseProfile(srcProfile);
CMCloseProfile(dstProfile);
// do whatever you need with the resulting color.RGB
If you've got a bunch of colors to convert all at once (it sounds
like you might have an array of them that you are displaying) you can
use an array of CMColors and convert them all at once.
--
Glenn Andreas email@hidden
mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.