--Boundary-00=_Ivvl/WtfqHV1tAB Content-Type: multipart/signed; charset="iso-8859-1"; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_Ivvl/r/C8L4kS3i"; name=" " Content-Transfer-Encoding: 7bit --Boundary-02=_Ivvl/r/C8L4kS3i Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Wednesday 22 October 2003 23:46, Patrick Julien wrote: > > Nice, can I see? > Well, yes... But a) It's untested -- really untested, and b) I'm not sure=20 whether I was barking up the right tree, and c) I probably made very silly= =20 mistakes. But here it is... =2D-=20 Boudewijn Rempt | http://www.valdyas.org/index2.html --Boundary-02=_Ivvl/r/C8L4kS3i Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/lvvIdaCcgCmN5d8RAplcAKC36iQ4qBBzge5kBqAwrLKo3foO0QCgtj2K ZslXlWWqkFJFpxFd4pHs1RY= =4ySz -----END PGP SIGNATURE----- --Boundary-02=_Ivvl/r/C8L4kS3i-- --Boundary-00=_Ivvl/WtfqHV1tAB Content-Type: text/x-c++src; charset="iso-8859-1"; name="kis_strategy_colorspace_cmyk.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_strategy_colorspace_cmyk.cc" /* * Copyright (c) 2003 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include "kis_image.h" #include "kis_strategy_colorspace_cmyk.h" #include "tiles/kispixeldata.h" namespace { const Q_INT32 MAX_CHANNEL_CMYK = 4; // Is it actually possible to have transparency with CMYK? const Q_INT32 MAX_CHANNEL_CMYKA = 5; } // Init static data ColorLUT KisStrategyColorSpaceCMYK::m_rgbLUT = ColorLUT(); KisStrategyColorSpaceCMYK::KisStrategyColorSpaceCMYK() : m_pixmap(RENDER_WIDTH * 2, RENDER_HEIGHT * 2) { m_buf = new QUANTUM[RENDER_WIDTH * RENDER_HEIGHT * MAX_CHANNEL_CMYKA]; } KisStrategyColorSpaceCMYK::~KisStrategyColorSpaceCMYK() { delete[] m_buf; } void KisStrategyColorSpaceCMYK::nativeColor(const KoColor& c, QUANTUM *dst) { dst[PIXEL_CYAN] = upscale( c.C() ); dst[PIXEL_MAGENTA] = upscale( c.M() ); dst[PIXEL_YELLOW] = upscale( c.Y() ); dst[PIXEL_BLACK] = upscale( c.K() ); } void KisStrategyColorSpaceCMYK::nativeColor(const KoColor& c, QUANTUM opacity, QUANTUM *dst) { dst[PIXEL_CYAN] = upscale( c.C() ); dst[PIXEL_MAGENTA] = upscale( c.M() ); dst[PIXEL_YELLOW] = upscale( c.Y() ); dst[PIXEL_BLACK] = upscale( c.K() ); dst[PIXEL_CMYK_ALPHA] = opacity; } void KisStrategyColorSpaceCMYK::nativeColor(const QColor& c, QUANTUM *dst) { KoColor k = KoColor( c ); dst[PIXEL_CYAN] = upscale( k.C() ); dst[PIXEL_MAGENTA] = upscale( k.M() ); dst[PIXEL_YELLOW] = upscale( k.Y() ); dst[PIXEL_BLACK] = upscale( k.K() ); } void KisStrategyColorSpaceCMYK::nativeColor(const QColor& c, QUANTUM opacity, QUANTUM *dst) { KoColor k = KoColor( c ); dst[PIXEL_CYAN] = upscale( k.C() ); dst[PIXEL_MAGENTA] = upscale( k.M() ); dst[PIXEL_YELLOW] = upscale( k.Y() ); dst[PIXEL_BLACK] = upscale( k.K() ); dst[PIXEL_CMYK_ALPHA] = opacity; } void KisStrategyColorSpaceCMYK::nativeColor(QRgb rgb, QUANTUM *dst) { KoColor k = KoColor(QColor( rgb )); dst[PIXEL_CYAN] = upscale( k.C() ); dst[PIXEL_MAGENTA] = upscale( k.M() ); dst[PIXEL_YELLOW] = upscale( k.Y() ); dst[PIXEL_BLACK] = upscale( k.K() ); } void KisStrategyColorSpaceCMYK::nativeColor(QRgb rgb, QUANTUM opacity, QUANTUM *dst) { KoColor k = KoColor(QColor( rgb )); dst[PIXEL_CYAN] = upscale( k.C() ); dst[PIXEL_MAGENTA] = upscale( k.M() ); dst[PIXEL_YELLOW] = upscale( k.Y() ); dst[PIXEL_BLACK] = upscale( k.K() ); dst[PIXEL_CMYK_ALPHA] = opacity; } void KisStrategyColorSpaceCMYK::render(KisImageSP projection, QPainter& painter, Q_INT32 x, Q_INT32 y, Q_INT32 width, Q_INT32 height) { if (projection) { KisTileMgrSP tm = projection -> tiles(); KisPixelDataSP pd = new KisPixelData; QImage img; pd -> mgr = 0; pd -> tile = 0; pd -> mode = TILEMODE_READ; pd -> x1 = x; pd -> x2 = x + width - 1; pd -> y1 = y; pd -> y2 = y + height - 1; pd -> width = pd -> x2 - pd -> x1 + 1; pd -> height = pd -> y2 - pd -> y1 + 1; pd -> depth = projection -> depth(); pd -> stride = pd -> depth * pd -> width; pd -> owner = false; pd -> data = m_buf; tm -> readPixelData(pd); img = QImage(pd -> width, pd -> height, pd -> depth * CHAR_BIT, 0, QImage::LittleEndian); img.setAlphaBuffer( true ); Q_INT32 i = 0; uchar *j = img.bits(); while ( i < pd ->stride * pd -> height ) { RGB r; // Check in LUT whether k already exists; if so, grab it, else CMYK c; c.c = *( pd->data + i + PIXEL_CYAN ); c.m = *( pd->data + i + PIXEL_MAGENTA ); c.y = *( pd->data + i + PIXEL_YELLOW ); c.k = *( pd->data + i + PIXEL_BLACK ); if ( m_rgbLUT.contains ( c ) ) { r = m_rgbLUT[c]; } else { // Accessing the rgba of KoColor automatically converts // from cmyk to rgb and caches the result KoColor k = KoColor(c.c, c.m, c.y, c.k ); // Store as little as possible r.r = k.R(); r.g = k.G(); r.b = k.B(); m_rgbLUT[c] = r; } // fix the pixel in QImage. *( j + PIXEL_ALPHA ) = *( pd->data + i + PIXEL_CMYK_ALPHA ); *( j + PIXEL_RED ) = r.r; *( j + PIXEL_GREEN ) = r.g; *( j + PIXEL_BLUE ) = r.b; i += MAX_CHANNEL_CMYKA; j += 4; } m_pixio.putImage(&m_pixmap, 0, 0, &img); painter.drawPixmap(x, y, m_pixmap, 0, 0, width, height); } } --Boundary-00=_Ivvl/WtfqHV1tAB Content-Type: text/x-chdr; charset="iso-8859-1"; name="kis_strategy_colorspace.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_strategy_colorspace.h" /* * Copyright (c) 2002 Patrick Julien * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if !defined KIS_STRATEGY_COLORSPACE_H_ #define KIS_STRATEGY_COLORSPACE_H_ #include #include #include #include "kis_global.h" #include "kis_types.h" class QPainter; class KisStrategyColorSpace : public KShared { public: KisStrategyColorSpace(); virtual ~KisStrategyColorSpace(); public: // The nativeColor methods take a given color and fill *dst with // the tuple that describes the colour for this particular strategy. virtual void nativeColor(const KoColor& c, QUANTUM *dst) = 0; virtual void nativeColor(const KoColor& c, QUANTUM opacity, QUANTUM *dst) = 0; virtual void nativeColor(const QColor& c, QUANTUM *dst) = 0; virtual void nativeColor(const QColor& c, QUANTUM opacity, QUANTUM *dst) = 0; virtual void nativeColor(QRgb rgb, QUANTUM *dst) = 0; virtual void nativeColor(QRgb rgb, QUANTUM opacity, QUANTUM *dst) = 0; virtual void render(KisImageSP projection, QPainter& painter, Q_INT32 x, Q_INT32 y, Q_INT32 width, Q_INT32 height) = 0; private: KisStrategyColorSpace(const KisStrategyColorSpace&); KisStrategyColorSpace& operator=(const KisStrategyColorSpace&); }; #endif // KIS_STRATEGY_COLORSPACE_H_ --Boundary-00=_Ivvl/WtfqHV1tAB Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kimageshop mailing list kimageshop@mail.kde.org http://mail.kde.org/mailman/listinfo/kimageshop --Boundary-00=_Ivvl/WtfqHV1tAB--