diff --git a/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.cpp b/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.cpp index 9b6dd898c1..85b2c02591 100644 --- a/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.cpp +++ b/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.cpp @@ -1,199 +1,222 @@ /* * 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 "LabColorSpace.h" #include #include #include "../compositeops/KoCompositeOps.h" #include #include LabU16ColorSpace::LabU16ColorSpace(const QString &name, KoColorProfile *p) : LcmsColorSpace(colorSpaceId(), name, TYPE_LABA_16, cmsSigLabData, p) { addChannel(new KoChannelInfo(i18n("Lightness"), 0 * sizeof(quint16), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(100, 100, 100))); addChannel(new KoChannelInfo(i18n("a*"), 1 * sizeof(quint16), 1, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(150, 150, 150))); addChannel(new KoChannelInfo(i18n("b*"), 2 * sizeof(quint16), 2, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(200, 200, 200))); addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(quint16), 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16))); init(); addStandardCompositeOps(this); } bool LabU16ColorSpace::willDegrade(ColorSpaceIndependence independence) const { if (independence == TO_RGBA8) { return true; } else { return false; } } KoColorSpace *LabU16ColorSpace::clone() const { return new LabU16ColorSpace(name(), profile()->clone()); } void LabU16ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const { const KoLabU16Traits::Pixel *p = reinterpret_cast(pixel); QDomElement labElt = doc.createElement("Lab"); qreal a, b; if (p->a <= KoLabColorSpaceMathsTraits::halfValueAB) { a = (p->a - KoLabColorSpaceMathsTraits::zeroValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB)); } else { a = 0.5 + (p->a - KoLabColorSpaceMathsTraits::halfValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } if (p->b <= KoLabColorSpaceMathsTraits::halfValueAB) { b = (p->b - KoLabColorSpaceMathsTraits::zeroValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB)); } else { b = 0.5 + (p->b - KoLabColorSpaceMathsTraits::halfValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } labElt.setAttribute("L", KisDomUtils::toString(KoColorSpaceMaths::scaleToA(p->L))); labElt.setAttribute("a", KisDomUtils::toString(a)); labElt.setAttribute("b", KisDomUtils::toString(b)); labElt.setAttribute("space", profile()->name()); colorElt.appendChild(labElt); } void LabU16ColorSpace::colorFromXML(quint8 *pixel, const QDomElement &elt) const { KoLabU16Traits::Pixel *p = reinterpret_cast(pixel); double a = KisDomUtils::toDouble(elt.attribute("a")); double b = KisDomUtils::toDouble(elt.attribute("b")); p->L = KoColorSpaceMaths::scaleToA(KisDomUtils::toDouble(elt.attribute("L"))); if (a <= 0.5) { p->a = KoLabColorSpaceMathsTraits::zeroValueAB + 2.0 * a * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB); } else { p->a = (KoLabColorSpaceMathsTraits::halfValueAB + 2.0 * (a - 0.5) * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } if (b <= 0.5) { p->b = KoLabColorSpaceMathsTraits::zeroValueAB + 2.0 * b * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB); } else { p->b = (KoLabColorSpaceMathsTraits::halfValueAB + 2.0 * (b - 0.5) * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } p->alpha = KoColorSpaceMathsTraits::max; } void LabU16ColorSpace::toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const { LabToLCH(channelValues[0],channelValues[1],channelValues[2], luma, sat, hue); } QVector LabU16ColorSpace::fromHSY(qreal *hue, qreal *sat, qreal *luma) const { QVector channelValues(4); LCHToLab(*luma, *sat, *hue, &channelValues[0],&channelValues[1],&channelValues[2]); channelValues[3]=1.0; return channelValues; } void LabU16ColorSpace::toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const { *y =channelValues[0]; *u=channelValues[1]; *v=channelValues[2]; } QVector LabU16ColorSpace::fromYUV(qreal *y, qreal *u, qreal *v) const { QVector channelValues(4); channelValues[0]=*y; channelValues[1]=*u; channelValues[2]=*v; channelValues[3]=1.0; return channelValues; } +quint8 LabU16ColorSpace::scaleToU8(const quint8 *srcPixel, qint32 channelIndex) const +{ + typename ColorSpaceTraits::channels_type c = ColorSpaceTraits::nativeArray(srcPixel)[channelIndex]; + qreal b = 0; + switch (channelIndex) { + case ColorSpaceTraits::L_pos: + b = c / ColorSpaceTraits::math_trait::unitValueL; + case ColorSpaceTraits::a_pos: + case ColorSpaceTraits::b_pos: + if (c <= ColorSpaceTraits::math_trait::halfValueAB) { + b = ((qreal)c - ColorSpaceTraits::math_trait::zeroValueAB) / (2.0 * (ColorSpaceTraits::math_trait::halfValueAB - ColorSpaceTraits::math_trait::zeroValueAB)); + } else { + b = 0.5 + ((qreal)c - ColorSpaceTraits::math_trait::halfValueAB) / (2.0 * (ColorSpaceTraits::math_trait::unitValueAB - ColorSpaceTraits::math_trait::halfValueAB)); + } + break; + default: + b = (c / ColorSpaceTraits::math_trait::unitValue); + break; + } + + return KoColorSpaceMaths::scaleToA(b); +} + void LabU16ColorSpace::convertChannelToVisualRepresentation(const quint8 *src, quint8 *dst, quint32 nPixels, const QBitArray selectedChannels, bool singleChannelAsColor) const { if (selectedChannels.count(true) == 1 && !singleChannelAsColor) { int selectedChannelPos = 0; for (int i = 0; i < selectedChannels.size(); ++i) { KoChannelInfo *channel = this->channels().at(i); if (selectedChannels.testBit(i) && channel->channelType() == KoChannelInfo::COLOR) { selectedChannelPos = i; } } for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) { for (uint channelIndex = 0; channelIndex < this->channelCount(); ++channelIndex) { KoChannelInfo *channel = this->channels().at(channelIndex); qint32 channelSize = channel->size(); if (channel->channelType() == KoChannelInfo::COLOR) { if (channelIndex == ColorSpaceTraits::L_pos) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + selectedChannelPos, channelSize); } else { reinterpret_cast(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize))[0] = ColorSpaceTraits::math_trait::halfValueAB; } } else if (channel->channelType() == KoChannelInfo::ALPHA) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), channelSize); } } } } else { for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) { for (uint channelIndex = 0; channelIndex < this->channelCount(); ++channelIndex) { KoChannelInfo *channel = this->channels().at(channelIndex); qint32 channelSize = channel->size(); if (selectedChannels.testBit(channelIndex)) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), channelSize); } else { ColorSpaceTraits::channels_type v; switch (channelIndex) { case ColorSpaceTraits::L_pos: v = ColorSpaceTraits::math_trait::halfValueL; break; case ColorSpaceTraits::a_pos: case ColorSpaceTraits::b_pos: v = ColorSpaceTraits::math_trait::halfValueAB; break; default: v = ColorSpaceTraits::math_trait::zeroValue; break; } reinterpret_cast(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize))[0] = v; } } } } } diff --git a/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.h b/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.h index c327133da5..3a943d91b9 100644 --- a/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.h +++ b/plugins/color/lcms2engine/colorspaces/lab_u16/LabColorSpace.h @@ -1,114 +1,115 @@ /* * 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. */ #ifndef LabU16ColorSpace_H_ #define LabU16ColorSpace_H_ #include "LcmsColorSpace.h" #include "KoColorModelStandardIds.h" #define TYPE_LABA_16 (COLORSPACE_SH(PT_Lab) | CHANNELS_SH(3) | BYTES_SH(2) | EXTRA_SH(1)) struct KoLabF32Traits; class LabU16ColorSpace : public LcmsColorSpace { public: LabU16ColorSpace(const QString &name, KoColorProfile *p); bool willDegrade(ColorSpaceIndependence independence) const override; static QString colorSpaceId() { return QString("LABA"); } KoID colorModelId() const override { return LABAColorModelID; } KoID colorDepthId() const override { return Integer16BitsColorDepthID; } virtual KoColorSpace *clone() const; void colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const override; void colorFromXML(quint8* pixel, const QDomElement& elt) const override; void toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const override; QVector fromHSY(qreal *hue, qreal *sat, qreal *luma) const override; void toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const override; QVector fromYUV(qreal *y, qreal *u, qreal *v) const override; + quint8 scaleToU8(const quint8 * srcPixel, qint32 channelIndex) const override; void convertChannelToVisualRepresentation(const quint8 *src, quint8 *dst, quint32 nPixels, const QBitArray selectedChannels, bool singleChannelAsColor) const override; }; class LabU16ColorSpaceFactory : public LcmsColorSpaceFactory { public: LabU16ColorSpaceFactory() : LcmsColorSpaceFactory(TYPE_LABA_16, cmsSigLabData) { } bool userVisible() const override { return true; } QString id() const override { return LabU16ColorSpace::colorSpaceId(); } QString name() const override { return QString("%1 (%2)").arg(LABAColorModelID.name()).arg(Integer16BitsColorDepthID.name()); } KoID colorModelId() const override { return LABAColorModelID; } KoID colorDepthId() const override { return Integer16BitsColorDepthID; } int referenceDepth() const override { return 16; } KoColorSpace *createColorSpace(const KoColorProfile *p) const override { return new LabU16ColorSpace(name(), p->clone()); } QString defaultProfile() const override { return "Lab identity built-in"; } }; #endif diff --git a/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.cpp b/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.cpp index 5346117840..634ee0564d 100644 --- a/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.cpp +++ b/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.cpp @@ -1,194 +1,217 @@ /* * 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 "LabU8ColorSpace.h" #include #include #include "../compositeops/KoCompositeOps.h" #include #include LabU8ColorSpace::LabU8ColorSpace(const QString &name, KoColorProfile *p) : LcmsColorSpace(colorSpaceId(), name, TYPE_LABA_8, cmsSigLabData, p) { addChannel(new KoChannelInfo(i18n("Lightness"), 0 * sizeof(quint8), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), QColor(100, 100, 100))); addChannel(new KoChannelInfo(i18n("a*"), 1 * sizeof(quint8), 1, KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), QColor(150, 150, 150))); addChannel(new KoChannelInfo(i18n("b*"), 2 * sizeof(quint8), 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), QColor(200, 200, 200))); addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(quint8), 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT8, sizeof(quint8))); init(); addStandardCompositeOps(this); } bool LabU8ColorSpace::willDegrade(ColorSpaceIndependence /*independence*/) const { return false; } KoColorSpace *LabU8ColorSpace::clone() const { return new LabU8ColorSpace(name(), profile()->clone()); } void LabU8ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const { const KoLabU8Traits::Pixel *p = reinterpret_cast(pixel); QDomElement labElt = doc.createElement("Lab"); double a, b; if (p->a <= KoLabColorSpaceMathsTraits::halfValueAB) { a = (p->a - KoLabColorSpaceMathsTraits::zeroValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB)); } else { a = 0.5 + (p->a - KoLabColorSpaceMathsTraits::halfValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } if (p->b <= KoLabColorSpaceMathsTraits::halfValueAB) { b = (p->b - KoLabColorSpaceMathsTraits::zeroValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB)); } else { b = 0.5 + (p->b - KoLabColorSpaceMathsTraits::halfValueAB) / (2.0 * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } labElt.setAttribute("L", KisDomUtils::toString(KoColorSpaceMaths::scaleToA(p->L))); labElt.setAttribute("a", KisDomUtils::toString(a)); labElt.setAttribute("b", KisDomUtils::toString(b)); labElt.setAttribute("space", profile()->name()); colorElt.appendChild(labElt); } void LabU8ColorSpace::colorFromXML(quint8 *pixel, const QDomElement &elt) const { KoLabU8Traits::Pixel *p = reinterpret_cast(pixel); double a = KisDomUtils::toDouble(elt.attribute("a")); double b = KisDomUtils::toDouble(elt.attribute("b")); p->L = KoColorSpaceMaths::scaleToA(KisDomUtils::toDouble(elt.attribute("L"))); if (a <= 0.5) { p->a = KoLabColorSpaceMathsTraits::zeroValueAB + 2.0 * a * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB); } else { p->a = (KoLabColorSpaceMathsTraits::halfValueAB + 2.0 * (a - 0.5) * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } if (b <= 0.5) { p->b = KoLabColorSpaceMathsTraits::zeroValueAB + 2.0 * b * (KoLabColorSpaceMathsTraits::halfValueAB - KoLabColorSpaceMathsTraits::zeroValueAB); } else { p->b = (KoLabColorSpaceMathsTraits::halfValueAB + 2.0 * (b - 0.5) * (KoLabColorSpaceMathsTraits::unitValueAB - KoLabColorSpaceMathsTraits::halfValueAB)); } p->alpha = KoColorSpaceMathsTraits::max; } void LabU8ColorSpace::toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const { LabToLCH(channelValues[0],channelValues[1],channelValues[2], luma, sat, hue); } QVector LabU8ColorSpace::fromHSY(qreal *hue, qreal *sat, qreal *luma) const { QVector channelValues(4); LCHToLab(*luma, *sat, *hue, &channelValues[0],&channelValues[1],&channelValues[2]); channelValues[3]=1.0; return channelValues; } void LabU8ColorSpace::toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const { *y =channelValues[0]; *u=channelValues[1]; *v=channelValues[2]; } QVector LabU8ColorSpace::fromYUV(qreal *y, qreal *u, qreal *v) const { QVector channelValues(4); channelValues[0]=*y; channelValues[1]=*u; channelValues[2]=*v; channelValues[3]=1.0; return channelValues; } +quint8 LabU8ColorSpace::scaleToU8(const quint8 *srcPixel, qint32 channelIndex) const +{ + typename ColorSpaceTraits::channels_type c = ColorSpaceTraits::nativeArray(srcPixel)[channelIndex]; + qreal b = 0; + switch (channelIndex) { + case ColorSpaceTraits::L_pos: + b = c / ColorSpaceTraits::math_trait::unitValueL; + case ColorSpaceTraits::a_pos: + case ColorSpaceTraits::b_pos: + if (c <= ColorSpaceTraits::math_trait::halfValueAB) { + b = ((qreal)c - ColorSpaceTraits::math_trait::zeroValueAB) / (2.0 * (ColorSpaceTraits::math_trait::halfValueAB - ColorSpaceTraits::math_trait::zeroValueAB)); + } else { + b = 0.5 + ((qreal)c - ColorSpaceTraits::math_trait::halfValueAB) / (2.0 * (ColorSpaceTraits::math_trait::unitValueAB - ColorSpaceTraits::math_trait::halfValueAB)); + } + break; + default: + b = (c / ColorSpaceTraits::math_trait::unitValue); + break; + } + + return KoColorSpaceMaths::scaleToA(b); +} + void LabU8ColorSpace::convertChannelToVisualRepresentation(const quint8 *src, quint8 *dst, quint32 nPixels, const QBitArray selectedChannels, bool singleChannelAsColor) const { if (selectedChannels.count(true) == 1 && !singleChannelAsColor) { int selectedChannelPos = 0; for (int i = 0; i < selectedChannels.size(); ++i) { KoChannelInfo *channel = this->channels().at(i); if (selectedChannels.testBit(i) && channel->channelType() == KoChannelInfo::COLOR) { selectedChannelPos = i; } } for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) { for (uint channelIndex = 0; channelIndex < this->channelCount(); ++channelIndex) { KoChannelInfo *channel = this->channels().at(channelIndex); qint32 channelSize = channel->size(); if (channel->channelType() == KoChannelInfo::COLOR) { if (channelIndex == ColorSpaceTraits::L_pos) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + selectedChannelPos, channelSize); } else { reinterpret_cast(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize))[0] = ColorSpaceTraits::math_trait::halfValueAB; } } else if (channel->channelType() == KoChannelInfo::ALPHA) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), channelSize); } } } } else { for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) { for (uint channelIndex = 0; channelIndex < this->channelCount(); ++channelIndex) { KoChannelInfo *channel = this->channels().at(channelIndex); qint32 channelSize = channel->size(); if (selectedChannels.testBit(channelIndex)) { memcpy(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), src + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize), channelSize); } else { ColorSpaceTraits::channels_type v; switch (channelIndex) { case ColorSpaceTraits::L_pos: v = ColorSpaceTraits::math_trait::halfValueL; break; case ColorSpaceTraits::a_pos: case ColorSpaceTraits::b_pos: v = ColorSpaceTraits::math_trait::halfValueAB; break; default: v = ColorSpaceTraits::math_trait::zeroValue; break; } reinterpret_cast(dst + (pixelIndex * ColorSpaceTraits::pixelSize) + (channelIndex * channelSize))[0] = v; } } } } } diff --git a/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.h b/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.h index f10f36f29a..8db9f5a49e 100644 --- a/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.h +++ b/plugins/color/lcms2engine/colorspaces/lab_u8/LabU8ColorSpace.h @@ -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. */ #ifndef LabU8ColorSpace_H_ #define LabU8ColorSpace_H_ #include "LcmsColorSpace.h" #include "KoColorModelStandardIds.h" #define TYPE_LABA_8 (COLORSPACE_SH(PT_Lab) | CHANNELS_SH(3) | BYTES_SH(1) | EXTRA_SH(1)) struct KoLabU8Traits; class LabU8ColorSpace : public LcmsColorSpace { public: LabU8ColorSpace(const QString &name, KoColorProfile *p); bool willDegrade(ColorSpaceIndependence independence) const override; static QString colorSpaceId() { return QString("LABAU8"); } KoID colorModelId() const override { return LABAColorModelID; } KoID colorDepthId() const override { return Integer8BitsColorDepthID; } virtual KoColorSpace* clone() const; void colorToXML(const quint8* pixel, QDomDocument& doc, QDomElement& colorElt) const override; void colorFromXML(quint8* pixel, const QDomElement& elt) const override; void toHSY(const QVector &channelValues, qreal *hue, qreal *sat, qreal *luma) const override; QVector fromHSY(qreal *hue, qreal *sat, qreal *luma) const override; void toYUV(const QVector &channelValues, qreal *y, qreal *u, qreal *v) const override; QVector fromYUV(qreal *y, qreal *u, qreal *v) const override; + quint8 scaleToU8(const quint8 * srcPixel, qint32 channelIndex) const override; void convertChannelToVisualRepresentation(const quint8 *src, quint8 *dst, quint32 nPixels, const QBitArray selectedChannels, bool singleChannelAsColor) const override; }; class LabU8ColorSpaceFactory : public LcmsColorSpaceFactory { public: LabU8ColorSpaceFactory() : LcmsColorSpaceFactory(TYPE_LABA_8, cmsSigLabData) {} bool userVisible() const override { return true; } QString id() const override { return LabU8ColorSpace::colorSpaceId(); } QString name() const override { return QString("%1 (%2)").arg(LABAColorModelID.name()).arg(Integer8BitsColorDepthID.name()); } KoID colorModelId() const override { return LABAColorModelID; } KoID colorDepthId() const override { return Integer8BitsColorDepthID; } int referenceDepth() const override { return 8; } KoColorSpace *createColorSpace(const KoColorProfile *p) const override { return new LabU8ColorSpace(name(), p->clone()); } QString defaultProfile() const override { return "Lab identity built-in"; } }; #endif