diff --git a/plugins/color/lcms2engine/colorspaces/rgb_f32/RgbF32ColorSpace.cpp b/plugins/color/lcms2engine/colorspaces/rgb_f32/RgbF32ColorSpace.cpp index e8308bbf41..623a80ffad 100644 --- a/plugins/color/lcms2engine/colorspaces/rgb_f32/RgbF32ColorSpace.cpp +++ b/plugins/color/lcms2engine/colorspaces/rgb_f32/RgbF32ColorSpace.cpp @@ -1,114 +1,116 @@ /* * Copyright (c) 2006 Cyrille Berger * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "RgbF32ColorSpace.h" #include #include #include "compositeops/KoCompositeOps.h" #include "compositeops/RgbCompositeOps.h" #include +#include +#include RgbF32ColorSpace::RgbF32ColorSpace(const QString &name, KoColorProfile *p) : LcmsColorSpace(colorSpaceId(), name, TYPE_RGBA_FLT, cmsSigRgbData, p) { const IccColorProfile *icc_p = dynamic_cast(p); Q_ASSERT(icc_p); QVector uiRanges(icc_p->getFloatUIMinMax()); Q_ASSERT(uiRanges.size() == 3); addChannel(new KoChannelInfo(i18n("Red"), 0 * sizeof(float), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(255, 0, 0), uiRanges[0])); addChannel(new KoChannelInfo(i18n("Green"), 1 * sizeof(float), 1, KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(0, 255, 0), uiRanges[1])); addChannel(new KoChannelInfo(i18n("Blue"), 2 * sizeof(float), 2, KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(0, 0, 255), uiRanges[2])); addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(float), 3, KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32, 4)); init(); addStandardCompositeOps(this); addCompositeOp(new RgbCompositeOpIn(this)); addCompositeOp(new RgbCompositeOpOut(this)); addCompositeOp(new RgbCompositeOpBumpmap(this)); } bool RgbF32ColorSpace::willDegrade(ColorSpaceIndependence independence) const { if (independence == TO_RGBA16) { return true; } else { return false; } } KoColorSpace *RgbF32ColorSpace::clone() const { return new RgbF32ColorSpace(name(), profile()->clone()); } void RgbF32ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const { const KoRgbF32Traits::Pixel *p = reinterpret_cast(pixel); QDomElement labElt = doc.createElement("RGB"); labElt.setAttribute("r", KisDomUtils::toString(KoColorSpaceMaths< KoRgbF32Traits::channels_type, qreal>::scaleToA(p->red))); labElt.setAttribute("g", KisDomUtils::toString(KoColorSpaceMaths< KoRgbF32Traits::channels_type, qreal>::scaleToA(p->green))); labElt.setAttribute("b", KisDomUtils::toString(KoColorSpaceMaths< KoRgbF32Traits::channels_type, qreal>::scaleToA(p->blue))); labElt.setAttribute("space", profile()->name()); colorElt.appendChild(labElt); } void RgbF32ColorSpace::colorFromXML(quint8 *pixel, const QDomElement &elt) const { KoRgbF32Traits::Pixel *p = reinterpret_cast(pixel); p->red = KoColorSpaceMaths< qreal, KoRgbF32Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("r"))); p->green = KoColorSpaceMaths< qreal, KoRgbF32Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("g"))); p->blue = KoColorSpaceMaths< qreal, KoRgbF32Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("b"))); p->alpha = 1.0; } void RgbF32ColorSpace::toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const { RGBToHSY(channelValues[0],channelValues[1],channelValues[2], hue, sat, luma, lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); } QVector RgbF32ColorSpace::fromHSY(qreal *hue, qreal *sat, qreal *luma) const { QVector channelValues(4); HSYToRGB(*hue, *sat, *luma, &channelValues[0],&channelValues[1],&channelValues[2], lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); channelValues[3]=1.0; return channelValues; } void RgbF32ColorSpace::toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const { RGBToYUV(channelValues[0],channelValues[1],channelValues[2], y, u, v, lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); } QVector RgbF32ColorSpace::fromYUV(qreal *y, qreal *u, qreal *v) const { QVector channelValues(4); YUVToRGB(*y, *u, *v, &channelValues[0],&channelValues[1],&channelValues[2], lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); channelValues[3]=1.0; return channelValues; } diff --git a/plugins/color/lcms2engine/colorspaces/rgb_u16/RgbU16ColorSpace.cpp b/plugins/color/lcms2engine/colorspaces/rgb_u16/RgbU16ColorSpace.cpp index 873980caad..981910f385 100644 --- a/plugins/color/lcms2engine/colorspaces/rgb_u16/RgbU16ColorSpace.cpp +++ b/plugins/color/lcms2engine/colorspaces/rgb_u16/RgbU16ColorSpace.cpp @@ -1,107 +1,108 @@ /* * Copyright (c) 2006 Cyrille Berger * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "RgbU16ColorSpace.h" #include #include #include "compositeops/KoCompositeOps.h" #include "compositeops/RgbCompositeOps.h" #include "kis_dom_utils.h" +#include RgbU16ColorSpace::RgbU16ColorSpace(const QString &name, KoColorProfile *p) : LcmsColorSpace(colorSpaceId(), name, TYPE_BGRA_16, cmsSigRgbData, p) { addChannel(new KoChannelInfo(i18n("Blue"), 0 * sizeof(quint16), 2, KoChannelInfo::COLOR, KoChannelInfo::UINT16, 2, QColor(0, 0, 255))); addChannel(new KoChannelInfo(i18n("Green"), 1 * sizeof(quint16), 1, KoChannelInfo::COLOR, KoChannelInfo::UINT16, 2, QColor(0, 255, 0))); addChannel(new KoChannelInfo(i18n("Red"), 2 * sizeof(quint16), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16, 2, QColor(255, 0, 0))); addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(quint16), 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT16, 2)); init(); addStandardCompositeOps(this); addCompositeOp(new RgbCompositeOpIn(this)); addCompositeOp(new RgbCompositeOpOut(this)); addCompositeOp(new RgbCompositeOpBumpmap(this)); } bool RgbU16ColorSpace::willDegrade(ColorSpaceIndependence independence) const { if (independence == TO_RGBA8) { return true; } else { return false; } } KoColorSpace *RgbU16ColorSpace::clone() const { return new RgbU16ColorSpace(name(), profile()->clone()); } void RgbU16ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const { const KoBgrU16Traits::Pixel *p = reinterpret_cast(pixel); QDomElement labElt = doc.createElement("RGB"); labElt.setAttribute("r", KisDomUtils::toString(KoColorSpaceMaths< KoBgrU16Traits::channels_type, qreal>::scaleToA(p->red))); labElt.setAttribute("g", KisDomUtils::toString(KoColorSpaceMaths< KoBgrU16Traits::channels_type, qreal>::scaleToA(p->green))); labElt.setAttribute("b", KisDomUtils::toString(KoColorSpaceMaths< KoBgrU16Traits::channels_type, qreal>::scaleToA(p->blue))); labElt.setAttribute("space", profile()->name()); colorElt.appendChild(labElt); } void RgbU16ColorSpace::colorFromXML(quint8 *pixel, const QDomElement &elt) const { KoBgrU16Traits::Pixel *p = reinterpret_cast(pixel); p->red = KoColorSpaceMaths< qreal, KoBgrU16Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("r"))); p->green = KoColorSpaceMaths< qreal, KoBgrU16Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("g"))); p->blue = KoColorSpaceMaths< qreal, KoBgrU16Traits::channels_type >::scaleToA(KisDomUtils::toDouble(elt.attribute("b"))); p->alpha = KoColorSpaceMathsTraits::max; } void RgbU16ColorSpace::toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const { RGBToHSY(channelValues[0],channelValues[1],channelValues[2], hue, sat, luma, lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); } QVector RgbU16ColorSpace::fromHSY(qreal *hue, qreal *sat, qreal *luma) const { QVector channelValues(4); HSYToRGB(*hue, *sat, *luma, &channelValues[0],&channelValues[1],&channelValues[2], lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); channelValues[3]=1.0; return channelValues; } void RgbU16ColorSpace::toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const { RGBToYUV(channelValues[0],channelValues[1],channelValues[2], y, u, v, lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); } QVector RgbU16ColorSpace::fromYUV(qreal *y, qreal *u, qreal *v) const { QVector channelValues(4); YUVToRGB(*y, *u, *v, &channelValues[0],&channelValues[1],&channelValues[2], lumaCoefficients()[0], lumaCoefficients()[1], lumaCoefficients()[2]); channelValues[3]=1.0; return channelValues; } diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpClear.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpClear.h deleted file mode 100644 index b372013237..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpClear.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPCLEAR_H -#define RGBCOMPOSITEOPCLEAR_H - -#include - -template -class RgbCompositeOpClear : public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpClear(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_CLEAR, i18n("Clear"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - Q_UNUSED(opacity); - Q_UNUSED(srcRowStart); - Q_UNUSED(srcRowStride); - Q_UNUSED(maskRowStart); - Q_UNUSED(maskRowStride); - - qint32 channelSize = sizeof(channels_type); - qint32 linesize = _CSTraits::channels_nb * channelSize * numColumns; - - if (channelFlags.isEmpty()) { - quint8 *d = dstRowStart; - while (rows-- > 0) { - memset(d, 0, linesize); - d += dstRowStride; - } - } else { - channels_type *d = reinterpret_cast(dstRowStart); - while (rows-- > 0) { - for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { - if (channelFlags.testBit(channel)) { - memset(d, 0, channelSize); - } - d++; - } - } - } - } - -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpColor.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpColor.h deleted file mode 100644 index 826680a048..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpColor.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPCOLOR_H -#define RGBCOMPOSITEOPCOLOR_H - -#include "KoColorSpaceMaths.h" -#include "KoColorConversions.h" -#include - -#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< channels_type, float>::scaleToA( v ) -#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, channels_type>::scaleToA( v ) - -template -class RgbCompositeOpColor : public KoCompositeOpAlphaBase<_CSTraits, RgbCompositeOpColor<_CSTraits>, true > -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpColor(KoColorSpace *cs) - : KoCompositeOpAlphaBase<_CSTraits, RgbCompositeOpColor<_CSTraits>, true >(cs, COMPOSITE_COLOR, i18n("Color"), KoCompositeOp::categoryMisc()) - { - } - - inline static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha) - { - return qMin(srcAlpha, dstAlpha); - } - - inline static void composeColorChannels(channels_type srcBlend, - const channels_type *src, - channels_type *dst, - bool allChannelFlags, - const QBitArray &channelFlags) - { - - float dstRed = SCALE_TO_FLOAT(dst[_CSTraits::red_pos]); - float dstGreen = SCALE_TO_FLOAT(dst[_CSTraits::green_pos]); - float dstBlue = SCALE_TO_FLOAT(dst[_CSTraits::blue_pos]); - - float srcHue; - float srcSaturation; - float srcLightness; - float dstHue; - float dstSaturation; - float dstLightness; - - float srcRed = SCALE_TO_FLOAT(src[_CSTraits::red_pos]); - float srcGreen = SCALE_TO_FLOAT(src[_CSTraits::green_pos]); - float srcBlue = SCALE_TO_FLOAT(src[_CSTraits::blue_pos]); - - RGBToHSL(srcRed, srcGreen, srcBlue, &srcHue, &srcSaturation, &srcLightness); - RGBToHSL(dstRed, dstGreen, dstBlue, &dstHue, &dstSaturation, &dstLightness); - HSLToRGB(srcHue, srcSaturation, dstLightness, &srcRed, &srcGreen, &srcBlue); - - if (allChannelFlags || channelFlags.testBit(_CSTraits::red_pos)) { - dst[_CSTraits::red_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcRed), SCALE_FROM_FLOAT(dstRed), srcBlend); - } - if (allChannelFlags || channelFlags.testBit(_CSTraits::green_pos)) { - dst[_CSTraits::green_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcGreen), SCALE_FROM_FLOAT(dstGreen), srcBlend); - } - if (allChannelFlags || channelFlags.testBit(_CSTraits::blue_pos)) { - dst[_CSTraits::blue_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcBlue), SCALE_FROM_FLOAT(dstBlue), srcBlend); - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDarken.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpDarken.h deleted file mode 100644 index 3487beddeb..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDarken.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPDARKEN_H -#define RGBCOMPOSITEOPDARKEN_H - -#include - -template -class RgbCompositeOpDarken : public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpDarken(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_DARKEN, i18n("Darken"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - while (rows > 0) { - const quint8 *mask = maskRowStart; - const channels_type *src = reinterpret_cast(srcRowStart); - channels_type *dst = reinterpret_cast(dstRowStart); - - for (int i = numColumns; i > 0; --i) { - channels_type srcAlpha = src[_CSTraits::alpha_pos]; - channels_type dstAlpha = dst[_CSTraits::alpha_pos]; - - srcAlpha = qMin(srcAlpha, dstAlpha); - - // apply the alphamask - if (mask != 0) { - if (*mask != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(*mask); - srcAlpha = KoColorSpaceMaths::multiply(srcAlpha, tmpOpacity); - } - mask++; - } - - if (srcAlpha != NATIVE_OPACITY_TRANSPARENT) { - if (opacity != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(opacity); - srcAlpha = KoColorSpaceMaths::multiply(src[_CSTraits::alpha_pos], tmpOpacity); - } - - channels_type srcBlend; - - if (dstAlpha == NATIVE_OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - channels_type newAlpha = dstAlpha + KoColorSpaceMaths::multiply(NATIVE_OPACITY_OPAQUE - dstAlpha, srcAlpha); - dst[KoBgrU8Traits::alpha_pos] = newAlpha; - - if (newAlpha != 0) { - srcBlend = KoColorSpaceMaths::divide(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::alpha_pos)) { - channels_type srcColor = src[channel]; - channels_type dstColor = dst[channel]; - - srcColor = qMin(srcColor, dstColor); - - channels_type newColor = KoColorSpaceMaths::blend(srcColor, dstColor, srcBlend); - - dst[channel] = newColor; - } - } - } - - src += _CSTraits::channels_nb; - dst += _CSTraits::channels_nb; - } - - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - if (maskRowStart) { - maskRowStart += maskRowStride; - } - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDiff.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpDiff.h deleted file mode 100644 index 22ba6c010a..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDiff.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPDIFF_H -#define RGBCOMPOSITEOPDIFF_H - -#include - -#define AbsoluteValue(x) ((x) < 0 ? -(x) : (x)) - -template -class RgbCompositeOpDiff : public KoCompositeOpAlphaBase<_CSTraits, RgbCompositeOpDiff<_CSTraits>, true > -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpDiff(KoColorSpace *cs) - : KoCompositeOpAlphaBase<_CSTraits, RgbCompositeOpDiff<_CSTraits>, true >(cs, COMPOSITE_DIFF, i18n("Diff"), KoCompositeOp::categoryMisc()) - { - } - - inline static channels_type selectAlpha(channels_type srcAlpha, channels_type dstAlpha) - { - return qMin(srcAlpha, dstAlpha); - } - - inline static void composeColorChannels(channels_type srcBlend, - const channels_type *src, - channels_type *dst, - bool allChannelFlags, - const QBitArray &channelFlags) - { - for (uint i = 0; i < _CSTraits::channels_nb; i++) { - if ((int)i != _CSTraits::alpha_pos && (allChannelFlags || channelFlags.testBit(i))) { - - channels_type diff = (channels_type) - AbsoluteValue(src[i] - (compositetype) dst[i]); - - dst[i] = KoColorSpaceMaths::blend(diff, dst[i], srcBlend); - } - } - } - -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDissolve.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpDissolve.h deleted file mode 100644 index f29f2475bd..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpDissolve.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPDISSOLVE_H -#define RGBCOMPOSITEOPDISSOLVE_H - -#include - -template -class RgbCompositeOpDissolve : public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpDissolve(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_DISSOLVE, i18n("Dissolve"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - Q_UNUSED(maskRowStart); - Q_UNUSED(maskRowStride); - - if (opacity == OPACITY_TRANSPARENT_U8) { - return; - } - - channels_type *d; - const channels_type *s; - - qint32 i; - - qreal sAlpha, dAlpha; - - while (rows-- > 0) { - d = reinterpret_cast(dstRowStart); - s = reinterpret_cast(srcRowStart); - for (i = numColumns; i > 0; i--, d += _CSTraits::channels_nb, s += _CSTraits::channels_nb) { - // XXX: correct? - if (s[_CSTraits::alpha_pos] == NATIVE_OPACITY_TRANSPARENT) { - continue; - } - - sAlpha = NATIVE_OPACITY_OPAQUE - s[_CSTraits::alpha_pos]; - dAlpha = NATIVE_OPACITY_OPAQUE - d[_CSTraits::alpha_pos]; - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::red_pos)) - d[_CSTraits::red_pos] = (channels_type)(((qreal) sAlpha * s[_CSTraits::red_pos] + - (NATIVE_OPACITY_OPAQUE - sAlpha) * d[_CSTraits::red_pos]) / NATIVE_OPACITY_OPAQUE + 0.5); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::green_pos)) - d[_CSTraits::green_pos] = (channels_type)(((qreal) sAlpha * s[_CSTraits::green_pos] + - (NATIVE_OPACITY_OPAQUE - sAlpha) * d[_CSTraits::green_pos]) / NATIVE_OPACITY_OPAQUE + 0.5); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::blue_pos)) - d[_CSTraits::blue_pos] = (channels_type)(((qreal) sAlpha * s[_CSTraits::blue_pos] + - (NATIVE_OPACITY_OPAQUE - sAlpha) * d[_CSTraits::blue_pos]) / NATIVE_OPACITY_OPAQUE + 0.5); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::alpha_pos)) { - d[_CSTraits::alpha_pos] = NATIVE_OPACITY_OPAQUE; - } - - } - dstRowStart += dstRowStride; - srcRowStart += srcRowStride; - - } - } - -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpHue.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpHue.h deleted file mode 100644 index 35e4f8920f..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpHue.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPHUE_H -#define RGBCOMPOSITEOPHUE_H - -#include "KoColorConversions.h" -#include - -#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< channels_type, float>::scaleToA( v ) -#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, channels_type>::scaleToA( v ) - -template -class RgbCompositeOpHue : public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpHue(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_HUE, i18n("Hue"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - channels_type *dst; - const channels_type *src; - - while (rows > 0) { - const quint8 *mask = maskRowStart; - src = reinterpret_cast(srcRowStart); - dst = reinterpret_cast(dstRowStart); - - for (int i = numColumns; i > 0; --i) { - channels_type srcAlpha = src[_CSTraits::alpha_pos]; - channels_type dstAlpha = dst[_CSTraits::alpha_pos]; - - srcAlpha = qMin(srcAlpha, dstAlpha); - - // apply the alphamask - if (mask != 0) { - if (*mask != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(*mask); - srcAlpha = KoColorSpaceMaths::multiply(srcAlpha, tmpOpacity); - } - mask++; - } - - if (srcAlpha != NATIVE_OPACITY_TRANSPARENT) { - - if (opacity != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(opacity); - srcAlpha = KoColorSpaceMaths::multiply(src[_CSTraits::alpha_pos], tmpOpacity); - } - - channels_type srcBlend; - - if (dstAlpha == NATIVE_OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - channels_type newAlpha = dstAlpha + KoColorSpaceMaths::multiply(NATIVE_OPACITY_OPAQUE - dstAlpha, srcAlpha); - dst[_CSTraits::alpha_pos] = newAlpha; - - if (newAlpha != 0) { - srcBlend = KoColorSpaceMaths::divide(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - float dstRed = SCALE_TO_FLOAT(dst[_CSTraits::red_pos]); - float dstGreen = SCALE_TO_FLOAT(dst[_CSTraits::green_pos]); - float dstBlue = SCALE_TO_FLOAT(dst[_CSTraits::blue_pos]); - - float srcHue; - float srcSaturation; - float srcValue; - float dstHue; - float dstSaturation; - float dstValue; - - float srcRed = SCALE_TO_FLOAT(src[_CSTraits::red_pos]); - float srcGreen = SCALE_TO_FLOAT(src[_CSTraits::green_pos]); - float srcBlue = SCALE_TO_FLOAT(src[_CSTraits::blue_pos]); - - RGBToHSV(srcRed, srcGreen, srcBlue, &srcHue, &srcSaturation, &srcValue); - RGBToHSV(dstRed, dstGreen, dstBlue, &dstHue, &dstSaturation, &dstValue); - - HSVToRGB(srcHue, dstSaturation, dstValue, &srcRed, &srcGreen, &srcBlue); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::red_pos)) { - dst[_CSTraits::red_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcRed), SCALE_FROM_FLOAT(dstRed), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::green_pos)) { - dst[_CSTraits::green_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcGreen), SCALE_FROM_FLOAT(dstGreen), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::blue_pos)) { - dst[_CSTraits::blue_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcBlue), SCALE_FROM_FLOAT(dstBlue), srcBlend); - } - } - - src += _CSTraits::channels_nb; - dst += _CSTraits::channels_nb; - } - - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - if (maskRowStart) { - maskRowStart += maskRowStride; - } - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpLighten.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpLighten.h deleted file mode 100644 index 1d560241fd..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpLighten.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPLIGHTEN_H -#define RGBCOMPOSITEOPLIGHTEN_H - -#include - -template -class RgbCompositeOpLighten : public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpLighten(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_LIGHTEN, i18n("Lighten"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - - while (rows > 0) { - const quint8 *mask = maskRowStart; - const channels_type *src = reinterpret_cast(srcRowStart); - channels_type *dst = reinterpret_cast(dstRowStart); - - for (int i = numColumns; i > 0; --i) { - channels_type srcAlpha = src[_CSTraits::alpha_pos]; - channels_type dstAlpha = dst[_CSTraits::alpha_pos]; - - srcAlpha = qMin(srcAlpha, dstAlpha); - - // apply the alphamask - if (mask != 0) { - if (*mask != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(*mask); - srcAlpha = KoColorSpaceMaths::multiply(srcAlpha, tmpOpacity); - } - mask++; - } - - if (srcAlpha != NATIVE_OPACITY_TRANSPARENT) { - - if (opacity != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(opacity); - srcAlpha = KoColorSpaceMaths::multiply(src[_CSTraits::alpha_pos], tmpOpacity); - } - - channels_type srcBlend; - - if (dstAlpha == NATIVE_OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - channels_type newAlpha = dstAlpha + KoColorSpaceMaths::multiply(NATIVE_OPACITY_OPAQUE - dstAlpha, srcAlpha); - dst[_CSTraits::alpha_pos] = newAlpha; - - if (newAlpha != 0) { - srcBlend = KoColorSpaceMaths::divide(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - for (int channel = 0; channel < MAX_CHANNEL_RGB; channel++) { - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::alpha_pos)) { - channels_type srcColor = src[channel]; - channels_type dstColor = dst[channel]; - - srcColor = qMax(srcColor, dstColor); - - channels_type newColor = KoColorSpaceMaths::blend(srcColor, dstColor, srcBlend); - - dst[channel] = newColor; - } - } - } - - src += _CSTraits::channels_nb; - dst += _CSTraits::channels_nb; - } - - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - if (maskRowStart) { - maskRowStart += maskRowStride; - } - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpSaturation.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpSaturation.h deleted file mode 100644 index 4dba82616b..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpSaturation.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPSATURATION_H -#define RGBCOMPOSITEOPSATURATION_H - -#include "KoColorConversions.h" -#include - -#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< channels_type, float>::scaleToA( v ) -#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, channels_type>::scaleToA( v ) - -template -class RgbCompositeOpSaturation: public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpSaturation(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_SATURATION, i18n("Saturation"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - - while (rows > 0) { - const quint8 *mask = maskRowStart; - const channels_type *src = reinterpret_cast(srcRowStart); - channels_type *dst = reinterpret_cast(dstRowStart); - - for (int i = numColumns; i > 0; --i) { - channels_type srcAlpha = src[_CSTraits::alpha_pos]; - channels_type dstAlpha = dst[_CSTraits::alpha_pos]; - - srcAlpha = qMin(srcAlpha, dstAlpha); - - // apply the alphamask - if (mask != 0) { - if (*mask != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(*mask); - srcAlpha = KoColorSpaceMaths::multiply(srcAlpha, tmpOpacity); - } - mask++; - } - - if (srcAlpha != NATIVE_OPACITY_TRANSPARENT) { - - if (opacity != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(opacity); - srcAlpha = KoColorSpaceMaths::multiply(src[_CSTraits::alpha_pos], tmpOpacity); - } - - channels_type srcBlend; - - if (dstAlpha == NATIVE_OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - channels_type newAlpha = dstAlpha + KoColorSpaceMaths::multiply(NATIVE_OPACITY_OPAQUE - dstAlpha, srcAlpha); - dst[_CSTraits::alpha_pos] = newAlpha; - - if (newAlpha != 0) { - srcBlend = KoColorSpaceMaths::divide(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - float dstRed = SCALE_TO_FLOAT(dst[_CSTraits::red_pos]); - float dstGreen = SCALE_TO_FLOAT(dst[_CSTraits::green_pos]); - float dstBlue = SCALE_TO_FLOAT(dst[_CSTraits::blue_pos]); - - float srcHue; - float srcSaturation; - float srcValue; - float dstHue; - float dstSaturation; - float dstValue; - - float srcRed = SCALE_TO_FLOAT(src[_CSTraits::red_pos]); - float srcGreen = SCALE_TO_FLOAT(src[_CSTraits::green_pos]); - float srcBlue = SCALE_TO_FLOAT(src[_CSTraits::blue_pos]); - - RGBToHSV(srcRed, srcGreen, srcBlue, &srcHue, &srcSaturation, &srcValue); - RGBToHSV(dstRed, dstGreen, dstBlue, &dstHue, &dstSaturation, &dstValue); - - HSVToRGB(dstHue, srcSaturation, dstValue, &srcRed, &srcGreen, &srcBlue); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::red_pos)) { - dst[_CSTraits::red_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcRed), SCALE_FROM_FLOAT(dstRed), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::green_pos)) { - dst[_CSTraits::green_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcGreen), SCALE_FROM_FLOAT(dstGreen), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::blue_pos)) { - dst[_CSTraits::blue_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcBlue), SCALE_FROM_FLOAT(dstBlue), srcBlend); - } - } - - src += _CSTraits::channels_nb; - dst += _CSTraits::channels_nb; - } - - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - if (maskRowStart) { - maskRowStart += maskRowStride; - } - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOpValue.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOpValue.h deleted file mode 100644 index fc1426ad9d..0000000000 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOpValue.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY const; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program const; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RGBCOMPOSITEOPVALUE_H -#define RGBCOMPOSITEOPVALUE_H - -#include "KoColorConversions.h" -#include - -#define SCALE_TO_FLOAT( v ) KoColorSpaceMaths< channels_type, float>::scaleToA( v ) -#define SCALE_FROM_FLOAT( v ) KoColorSpaceMaths< float, channels_type>::scaleToA( v ) - -template -class RgbCompositeOpValue: public KoCompositeOp -{ - typedef typename _CSTraits::channels_type channels_type; - typedef typename KoColorSpaceMathsTraits::compositetype compositetype; - -public: - - RgbCompositeOpValue(KoColorSpace *cs) - : KoCompositeOp(cs, COMPOSITE_VALUE, i18nc("HSV Value","Value"), "") - { - } - - using KoCompositeOp::composite; - - void composite(quint8 *dstRowStart, qint32 dstRowStride, - const quint8 *srcRowStart, qint32 srcRowStride, - const quint8 *maskRowStart, qint32 maskRowStride, - qint32 rows, qint32 numColumns, - quint8 opacity, - const QBitArray &channelFlags) const override - { - - while (rows > 0) { - const quint8 *mask = maskRowStart; - const channels_type *src = reinterpret_cast(srcRowStart); - channels_type *dst = reinterpret_cast(dstRowStart); - - for (int i = numColumns; i > 0; --i) { - channels_type srcAlpha = src[_CSTraits::alpha_pos]; - channels_type dstAlpha = dst[_CSTraits::alpha_pos]; - - srcAlpha = qMin(srcAlpha, dstAlpha); - - // apply the alphamask - if (mask != 0) { - if (*mask != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(*mask); - srcAlpha = KoColorSpaceMaths::multiply(srcAlpha, tmpOpacity); - } - mask++; - } - - if (srcAlpha != NATIVE_OPACITY_TRANSPARENT) { - - if (opacity != OPACITY_OPAQUE_U8) { - channels_type tmpOpacity = KoColorSpaceMaths::scaleToA(opacity); - srcAlpha = KoColorSpaceMaths::multiply(src[_CSTraits::alpha_pos], tmpOpacity); - } - - channels_type srcBlend; - - if (dstAlpha == NATIVE_OPACITY_OPAQUE) { - srcBlend = srcAlpha; - } else { - channels_type newAlpha = dstAlpha + KoColorSpaceMaths::multiply(NATIVE_OPACITY_OPAQUE - dstAlpha, srcAlpha); - dst[_CSTraits::alpha_pos] = newAlpha; - - if (newAlpha != 0) { - srcBlend = KoColorSpaceMaths::divide(srcAlpha, newAlpha); - } else { - srcBlend = srcAlpha; - } - } - - float dstRed = SCALE_TO_FLOAT(dst[_CSTraits::red_pos]); - float dstGreen = SCALE_TO_FLOAT(dst[_CSTraits::green_pos]); - float dstBlue = SCALE_TO_FLOAT(dst[_CSTraits::blue_pos]); - - float srcHue; - float srcSaturation; - float srcValue; - float dstHue; - float dstSaturation; - float dstValue; - - float srcRed = SCALE_TO_FLOAT(src[_CSTraits::red_pos]); - float srcGreen = SCALE_TO_FLOAT(src[_CSTraits::green_pos]); - float srcBlue = SCALE_TO_FLOAT(src[_CSTraits::blue_pos]); - - RGBToHSV(srcRed, srcGreen, srcBlue, &srcHue, &srcSaturation, &srcValue); - RGBToHSV(dstRed, dstGreen, dstBlue, &dstHue, &dstSaturation, &dstValue); - - HSVToRGB(dstHue, dstSaturation, srcValue, &srcRed, &srcGreen, &srcBlue); - - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::red_pos)) { - dst[_CSTraits::red_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcRed), SCALE_FROM_FLOAT(dstRed), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::green_pos)) { - dst[_CSTraits::green_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcGreen), SCALE_FROM_FLOAT(dstGreen), srcBlend); - } - if (channelFlags.isEmpty() || channelFlags.testBit(_CSTraits::blue_pos)) { - dst[_CSTraits::blue_pos] = KoColorSpaceMaths::blend(SCALE_FROM_FLOAT(srcBlue), SCALE_FROM_FLOAT(dstBlue), srcBlend); - } - } - - src += _CSTraits::channels_nb; - dst += _CSTraits::channels_nb; - } - - rows--; - srcRowStart += srcRowStride; - dstRowStart += dstRowStride; - if (maskRowStart) { - maskRowStart += maskRowStride; - } - } - } -}; - -#endif diff --git a/plugins/color/lcms2engine/compositeops/RgbCompositeOps.h b/plugins/color/lcms2engine/compositeops/RgbCompositeOps.h index c4ac1b266a..c1b801029d 100644 --- a/plugins/color/lcms2engine/compositeops/RgbCompositeOps.h +++ b/plugins/color/lcms2engine/compositeops/RgbCompositeOps.h @@ -1,77 +1,68 @@ /* * Copyright (c) 2006 Boudewijn Rempt * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY const; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program const; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Some code is derived from GraphicsMagick/magick/composite.c and is subject to the following license and copyright: Copyright (C) 2002 GraphicsMagick Group, an organization dedicated to making software imaging solutions freely available. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files ("GraphicsMagick"), to deal in GraphicsMagick without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of GraphicsMagick, and to permit persons to whom GraphicsMagick is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of GraphicsMagick. The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall GraphicsMagick Group be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with GraphicsMagick or the use or other dealings in GraphicsMagick. Except as contained in this notice, the name of the GraphicsMagick Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in GraphicsMagick without prior written authorization from the GraphicsMagick Group. Other code is derived from gwenview/src/qxcfi.* - this is released under the terms of the LGPL */ #ifndef RGBCOMPOSITEOPS_H #define RGBCOMPOSITEOPS_H #include "KoColorSpaceConstants.h" #define NATIVE_OPACITY_OPAQUE KoColorSpaceMathsTraits::unitValue #define NATIVE_OPACITY_TRANSPARENT KoColorSpaceMathsTraits::zeroValue const qint32 MAX_CHANNEL_RGB = 3; #include "RgbCompositeOpIn.h" #include "RgbCompositeOpOut.h" -#include "RgbCompositeOpDiff.h" #include "RgbCompositeOpBumpmap.h" -#include "RgbCompositeOpClear.h" -#include "RgbCompositeOpDissolve.h" -#include "RgbCompositeOpDarken.h" -#include "RgbCompositeOpLighten.h" -#include "RgbCompositeOpHue.h" -#include "RgbCompositeOpSaturation.h" -#include "RgbCompositeOpValue.h" -#include "RgbCompositeOpColor.h" #endif