From koffice-devel Thu Oct 23 22:11:37 2003 From: Boudewijn Rempt Date: Thu, 23 Oct 2003 22:11:37 +0000 To: koffice-devel Subject: Re: KoColor && CMYK -> RGB X-MARC-Message: https://marc.info/?l=koffice-devel&m=106694724102168 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0487959209==" --===============0487959209== Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_cIFm/vDImTDmUZ3"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit --Boundary-02=_cIFm/vDImTDmUZ3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline 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. Sin= ce > 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 =3D (R < G) ? R : G; > *K =3D (min < B) ? min : B; > > *C =3D 255 - (R - *K); > *M =3D 255 - (G - *K); > *Y =3D 255 - (B - *K); > } > I've changed this to=20 void KoColor::RGBtoCMYK(int R, int G, int B, int *C, int *M, int *Y, int *K) { *C =3D 255 - R; *M =3D 255 - G; *Y =3D 255 - B; int min =3D (*C < *M) ? *C : *M; *K =3D (min < *Y) ? min : *Y; *C =3D *C - *K; *M =3D *M - *K; *Y =3D *Y - *K; } In the end, following Foley etc., who I should have consulted first, instea= d=20 of googling. The difference with the previous being that I first convert to= =20 CMY, instead of subtracting the K from RG and B.=20 Anyway, since this is a real, life koffice lib -- can I check this in? It=20 seems to produce the right results in Krita. =2D-=20 Boudewijn Rempt | http://www.valdyas.org/index2.html --Boundary-02=_cIFm/vDImTDmUZ3 Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/mFIcdaCcgCmN5d8RAqxwAKCAl8cZmwP4xOfApgOnGQqNgmanEACdFyKP /0Q7Aesm1czBZxhRMkn/Ea0= =fbIN -----END PGP SIGNATURE----- --Boundary-02=_cIFm/vDImTDmUZ3-- --===============0487959209== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel --===============0487959209==--