From koffice-devel Thu Oct 23 21:09:19 2003 From: Boudewijn Rempt Date: Thu, 23 Oct 2003 21:09:19 +0000 To: koffice-devel Subject: KoColor && CMYK -> RGB X-MARC-Message: https://marc.info/?l=koffice-devel&m=106694399131212 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0096244401==" --===============0096244401== Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_DOEm/C4p0fA2JFc"; charset="us-ascii" Content-Transfer-Encoding: 7bit --Boundary-02=_DOEm/C4p0fA2JFc Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline Well, my CMYK strategy works now without crashes -- and it gets called, too= ,=20 so that's nice. But I fear that there might be a bug in KoColor. Since=20 KoColor isn't used anywhere but on in Krita, but is still in the koffice li= b,=20 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); } The color conversion website (http://www.easyrgb.com/math.php?MATH=3DM11#te= xt11)=20 doesn't give a direct rgb-> cmyk, but advises: //inp_R =3D From 0 to 255 //inp_G =3D From 0 to 255 //inp_B =3D From 0 to 255 out_C =3D 1 - ( inp_R / 255 ) out_M =3D 1 - ( inp_G / 255 ) out_Y =3D 1 - ( inp_B / 255 ) followed by: //inp_C =3D From 0 to 1 //inp_M =3D From 0 to 1 //inp_Y =3D From 0 to 1 var_K =3D 1 if ( inp_C < var_K ) var_K =3D inp_C if ( inp_M < var_K ) var_K =3D inp_M if ( inp_Y < var_K ) var_K =3D inp_Y out_C =3D ( inp_C - var_K ) / (1 - var_K ) out_M =3D ( inp_M - var_K ) / (1 - var_K ) out_Y =3D ( inp_Y - var_K ) / (1 - var_K ) out_K =3D var_K Which is obviously rather more costly, with all the divisions... I'm hackin= g=20 this in for now, to see what it does, but does anyone have a nice bit of ma= th=20 that makes this cheaper? =2D-=20 Boudewijn Rempt | http://www.valdyas.org/index2.html --Boundary-02=_DOEm/C4p0fA2JFc Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/mEOCdaCcgCmN5d8RAqlEAKDweUFfJrgcV8BAW03VMvr17wMWRQCg7Qzy XlfTLIMjNo/vcbwtskUklak= =wbed -----END PGP SIGNATURE----- --Boundary-02=_DOEm/C4p0fA2JFc-- --===============0096244401== 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 --===============0096244401==--