Warning, file /office/calligra/libs/pigment/KoLabDarkenColorTransformation.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> 0003 * Copyright (c) 2005-2006 C. Boemann <cbo@boemann.dk> 0004 * Copyright (c) 2004,2006-2007 Cyrille Berger <cberger@cberger.net> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef _KO_LAB_DARKEN_COLOR_TRANSFORMATION_H_ 0023 #define _KO_LAB_DARKEN_COLOR_TRANSFORMATION_H_ 0024 0025 #if !defined _MSC_VER 0026 #pragma GCC diagnostic ignored "-Wcast-align" 0027 #endif 0028 0029 #include "KoColorTransformation.h" 0030 0031 template<typename _lab_channels_type_> 0032 struct KoLabDarkenColorTransformation : public KoColorTransformation { 0033 KoLabDarkenColorTransformation(qint32 shade, bool compensate, qreal compensation, const KoColorSpace *colorspace) : m_colorSpace(colorspace), m_shade(shade), m_compensate(compensate), m_compensation(compensation) { 0034 0035 } 0036 void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override { 0037 *((quint32 *)dst)=*((const quint32 *)src); 0038 QColor c; 0039 0040 for (unsigned int i = 0; i < nPixels*m_colorSpace->pixelSize(); i+=m_colorSpace->pixelSize()) { 0041 if (m_compensate) { 0042 m_colorSpace->toQColor(src+i,&c); 0043 c.setRed((c.red()*m_shade)/(m_compensation*255)); 0044 c.setGreen((c.green()*m_shade)/(m_compensation*255)); 0045 c.setBlue((c.blue()*m_shade)/(m_compensation*255)); 0046 m_colorSpace->fromQColor(c,dst+i); 0047 } else { 0048 m_colorSpace->toQColor(src+i,&c); 0049 c.setRed((c.red()*m_shade)/255); 0050 c.setGreen((c.green()*m_shade)/255); 0051 c.setBlue((c.blue()*m_shade)/255); 0052 m_colorSpace->fromQColor(c,dst+i); 0053 } 0054 } 0055 } 0056 const KoColorSpace* m_colorSpace; 0057 const KoColorConversionTransformation* m_defaultToLab; 0058 const KoColorConversionTransformation* m_defaultFromLab; 0059 qint32 m_shade; 0060 bool m_compensate; 0061 qreal m_compensation; 0062 }; 0063 0064 #endif