Warning, file /office/calligra/libs/pigment/KoMultipleColorConversionTransformation.cpp 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) 2007 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "KoMultipleColorConversionTransformation.h" 0021 0022 #include <QList> 0023 0024 #include <KoColorSpace.h> 0025 0026 struct Q_DECL_HIDDEN KoMultipleColorConversionTransformation::Private { 0027 QList<KoColorConversionTransformation*> transfos; 0028 quint32 maxPixelSize; 0029 }; 0030 0031 0032 KoMultipleColorConversionTransformation::KoMultipleColorConversionTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) 0033 : KoColorConversionTransformation(srcCs, dstCs, renderingIntent, conversionFlags) 0034 , d(new Private) 0035 { 0036 d->maxPixelSize = qMax(srcCs->pixelSize(), dstCs->pixelSize()); 0037 } 0038 KoMultipleColorConversionTransformation::~KoMultipleColorConversionTransformation() 0039 { 0040 foreach(KoColorConversionTransformation* transfo, d->transfos) { 0041 delete transfo; 0042 } 0043 delete d; 0044 } 0045 void KoMultipleColorConversionTransformation::appendTransfo(KoColorConversionTransformation* transfo) 0046 { 0047 d->transfos.append(transfo); 0048 d->maxPixelSize = qMax(d->maxPixelSize, transfo->srcColorSpace()->pixelSize()); 0049 d->maxPixelSize = qMax(d->maxPixelSize, transfo->dstColorSpace()->pixelSize()); 0050 } 0051 void KoMultipleColorConversionTransformation::transform(const quint8 *src, quint8 *dst, qint32 nPixels) const 0052 { 0053 Q_ASSERT(d->transfos.size() > 1); // Be sure to have a more than one transformation 0054 quint8 *buff1 = new quint8[d->maxPixelSize*nPixels]; 0055 quint8 *buff2 = 0; 0056 if (d->transfos.size() > 2) { 0057 buff2 = new quint8[d->maxPixelSize*nPixels]; // a second buffer is needed 0058 } 0059 d->transfos.first()->transform(src, buff1, nPixels); 0060 int lastIndex = d->transfos.size() - 2; 0061 for (int i = 1; i <= lastIndex; i++) { 0062 d->transfos[i]->transform(buff1, buff2, nPixels); 0063 quint8* tmp = buff1; 0064 buff1 = buff2; 0065 buff2 = tmp; 0066 } 0067 d->transfos.last()->transform(buff1, dst, nPixels); 0068 delete [] buff2; 0069 delete [] buff1; 0070 }