[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: KoColor && CMYK -> RGB
From: Leonard Rosenthol <leonardr () lazerware ! com>
Date: 2003-10-24 0:10:27
[Download RAW message or body]
First, keep in mind that algorithmic color conversion between RGB &
CMYK will NEVER give you colors that an pro considers acceptable -
you MUST use ICCProfiles (see lcms- http://www.littlecms.org).
however, if you insist on algorithmic OR need a fallback for when
ICC's arent' available, here are a set of algorithms that I use in my
commercial color conversion software.
void ColorUtils::CMYKToRGB( ASFixed inCyan, ASFixed inMagenta,
ASFixed inYellow, ASFixed inBlack,
ASFixed& outRed, ASFixed& outGreen, ASFixed& outBlue )
{
#if 0 // standard/simple algorithm
outRed = clip01( (1.0 - inCyan) * (1.0 - inBlack) );
outGreen = clip01( (1.0 - inMagenta) * (1.0 - inBlack) );
outBlue = clip01( (1.0 - inYellow) * (1.0 - inBlack) );
#else // from Xpdf
double c, m, y, aw, ac, am, ay, ar, ag, ab;
c = clip01( inCyan + inBlack );
m = clip01( inMagenta + inBlack );
y = clip01( inYellow + inBlack );
aw = (1-c) * (1-m) * (1-y);
ac = c * (1-m) * (1-y);
am = (1-c) * m * (1-y);
ay = (1-c) * (1-m) * y;
ar = (1-c) * m * y;
ag = c * (1-m) * y;
ab = c * m * (1-y);
outRed = clip01(aw + 0.9137*am + 0.9961*ay + 0.9882*ar);
outGreen = clip01(aw + 0.6196*ac + ay + 0.5176*ag);
outBlue = clip01(aw + 0.7804*ac + 0.5412*am + 0.0667*ar +
0.2118*ag + 0.4863*ab);
#endif
}
void ColorUtils::RGBToCMYK( ASFixed inRed, ASFixed inGreen, ASFixed inBlue,
ASFixed& outCyan, ASFixed& outMagenta,
ASFixed& outYellow, ASFixed& outBlack)
{
double c, m, y, k;
c = clip01( 1.0 - inRed );
m = clip01( 1.0 - inGreen );
y = clip01( 1.0 - inBlue );
k = c;
if (m < k) {
k = m;
}
if (y < k) {
k = y;
}
outCyan = c - k;
outMagenta = m - k;
outYellow = y - k;
outBlack = k;
}
Leonard
--
---------------------------------------------------------------------------
Leonard Rosenthol <mailto:leonardr@lazerware.com>
<http://www.lazerware.com>
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic