KoColor && CMYK -> RGB

Boudewijn Rempt boud at valdyas.org
Fri Oct 24 01:11:37 CEST 2003


On Thursday 23 October 2003 23:09, Boudewijn Rempt wrote:
> Well, my CMYK strategy works now without crashes -- and it gets called,
> too, so that's nice. But I fear that there might be a bug in KoColor. Since
> KoColor isn't used anywhere but on in Krita, but is still in the koffice
> lib, I crossposted.  Is there still anyone maintaining this useful class?
>
> Anyway, given a nice, white RGB color (255, 255, 255), this function
> gives (255, 255, 255, 255) -- which is as black as can be.
>
> void KoColor::RGBtoCMYK(int R, int G, int B, int *C, int *M, int *Y, int
> *K) {
>   int min = (R < G) ? R : G;
>   *K = (min < B) ? min : B;
>
>   *C = 255 - (R - *K);
>   *M = 255 - (G - *K);
>   *Y = 255 - (B - *K);
> }
>

I've changed this to 

void KoColor::RGBtoCMYK(int R, int G, int B, int *C, int *M, int *Y, int *K)
{
    *C = 255 - R;
    *M = 255 - G;
    *Y = 255 - B;

    int min = (*C < *M) ? *C : *M;
    *K = (min < *Y) ? min : *Y;

    *C = *C - *K;
    *M = *M - *K;
    *Y = *Y - *K;
}

In the end, following Foley etc., who I should have consulted first, instead 
of googling. The difference with the previous being that I first convert to 
CMY, instead of subtracting the K from RG and B. 

Anyway, since this is a real, life koffice lib -- can I check this in? It 
seems to produce the right results in Krita.
-- 
Boudewijn Rempt | http://www.valdyas.org/index2.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: signature
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20031024/81948c60/attachment.bin


More information about the kimageshop mailing list