From kde-kimageshop Sun Oct 23 19:06:23 2005 From: Boudewijn Rempt Date: Sun, 23 Oct 2005 19:06:23 +0000 To: kde-kimageshop Subject: Inversion in colorspaces Message-Id: <200510232106.26669.boud () valdyas ! org> X-MARC-Message: https://marc.info/?l=kde-kimageshop&m=113009438707627 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1227098717==" --===============1227098717== Content-Type: multipart/signed; boundary="nextPart1592008.vtnHVbQTzO"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1592008.vtnHVbQTzO Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This turns out to be quite a fun topic... I haven't got it working complete= ly.=20 16-bit rgba works perfectly, but, for 8-bit rgb, I get a blank image back i= f=20 I go through xyz (I will add an optimized 8-bit rgb function later, but thi= s=20 is for testing). I'm not sure why, maybe someone else has an idea. This is= =20 the code: void KisAbstractColorSpace::invertColor(Q_UINT8 * src, Q_INT32 nPixels) { if ( m_defaultToXYZ !=3D 0 && m_defaultFromXYZ !=3D 0 ) { KisColorSpace * xyz =3D m_parent->getXYZ16(); =20 Q_UINT32 psize =3D xyz->pixelSize(); if ( m_conversionCache.size() < nPixels * psize ) { m_conversionCache.resize( nPixels * psize, QGArray::SpeedOptim = ); } cmsDoTransform( m_defaultToXYZ, const_cast( src ),=20 m_conversionCache.data(), nPixels); xyz->invertColor(m_conversionCache.data(), nPixels); cmsDoTransform( m_defaultFromXYZ, m_conversionCache.data(),=20 const_cast( src ), nPixels); } else { ... } } The transforms to and back XYZ work, I tested that by commenting out the ca= ll=20 to xyz->invertColor().=20 void KisXyzColorSpace::invertColor(Q_UINT8 * src, Q_INT32 nPixels) { Q_INT32 pSize =3D pixelSize(); =20 while (nPixels--) { Q_UINT16 * p =3D reinterpret_cast(src); p[PIXEL_X] =3D UINT16_MAX - p[PIXEL_X]; p[PIXEL_Y] =3D UINT16_MAX - p[PIXEL_Y]; p[PIXEL_Z] =3D UINT16_MAX - p[PIXEL_Z]; src +=3D pSize; } } An example of the xyz values before and after inverting: krita: Before X 2860, Y 3377, z 2426 krita: After X 62675, Y 62158, z 63109 Looks good, so everything should work... But it doesnt :-(. Anyway, there's also the intriguing mention of building an inversion lut in= =20 the lcms documentation, but I don't understand it at all... Perhaps Casper= =20 can take a look at that? =2D-=20 Boudewijn Rempt=20 http://www.valdyas.org/fading/index.cgi --nextPart1592008.vtnHVbQTzO Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBDW98ydaCcgCmN5d8RAkGzAJ4uKAYLEw00oPKti5808ob/2d8EpwCfcXgH Qq5gw5o35CpB2nmFgE/iLrw= =n2Hu -----END PGP SIGNATURE----- --nextPart1592008.vtnHVbQTzO-- --===============1227098717== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kimageshop mailing list kimageshop@kde.org https://mail.kde.org/mailman/listinfo/kimageshop --===============1227098717==--