On 2/5/07, Peter Rolf
Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Mojca Miklavec wrote:
On 2/4/07, Hans Hagen
wrote: Peter Rolf wrote:
But to my surprise ConTeXt automatically converts my RGB colors (even the MP defined ones), except that the final colors are in the CMY instead of CMYK color space. All I want is a true RGBtoCMYK conversion. I know about the calculating limitations in TeX, so I can wait for an implemetation of that macro in LuaTeX.
but even then ... we need a formula ...
Most pages on the internet list the following simple conversion formula:
C' = 1 - (R/range) C = (C' - K') / (1 - K') M' = 1 - (G/range) M = (M' - K') / (1 - K') Y' = 1 - (B/range) Y = (Y' - K') / (1 - K') K' = MIN(C',Y',M') K = K'
In the special case of K'=1, use (0,0,0,1)
(I'm not a TeX guru, but I assume that conversion with current macros should not be much more difficult than conversion with luaTeX.)
this is what we have now
\def\doconvertRGBtoCMYK#1\to#2% {\colordimen#1\points \multiply\colordimen \plusthousand \colorcount\colordimen \advance\colorcount \medcard \divide\colorcount \maxcard \colorcount-\colorcount \advance\colorcount \plusthousand \edef#2{\realcolorvalue\colorcount}}
\def\convertRGBtoCMYK#1#2#3% {\doconvertRGBtoCMYK#1\to\@@cl@@c \doconvertRGBtoCMYK#2\to\@@cl@@m \doconvertRGBtoCMYK#3\to\@@cl@@y \let\@@cl@@k\@@cl@@z}
well, you can spent the rest of the evening writing an alternative
Since writing reports can sometimes be really boring, you can test if the following works, but please don't ask me what it does ;)
I doubt that writing such macros is a better activity ;) Thanks to you Mojca for this nice and clean structured solution.
Nice and clean structured??? I hope that you're joking ... ;)
The conversion works ok, but the accuracy is not good enough. I have translated some parts into etex (better accuracy in divisions using dim|numexpr), but it's still lacks of accuracy. I will try to use a special macro (blow up numerator) for all divisions.
The problem with accuracy appears at more steps: - I used RGB->CMY->CMYK conversion, CMY is round off to 3 decimal places - I almost surely "forgot" to round the result - (c-k)/(1-k) probably works disastrous for large values of k - (I had quite some problems understanding how conversion between counters and dimensions works, and even more problems to find a clean solution - eTeX is surely a better choice) Mojca (no ConTeXt on this computer, so I'll reply about the rest later)