Krita Source Code Documentation
Loading...
Searching...
No Matches
KoLabColorSpace Class Reference

#include <KoLabColorSpace.h>

+ Inheritance diagram for KoLabColorSpace:

Public Member Functions

virtual KoColorSpaceclone () const
 
void convertChannelToVisualRepresentation (const quint8 *src, quint8 *dst, quint32 nPixels, const QBitArray selectedChannels) const override
 
void convertChannelToVisualRepresentation (const quint8 *src, quint8 *dst, quint32 nPixels, const qint32 selectedChannelIndex) const override
 
QVector< double > fromHSY (qreal *hue, qreal *sat, qreal *luma) const override
 
void fromQColor (const QColor &color, quint8 *dst) const override
 
QVector< double > fromYUV (qreal *y, qreal *u, qreal *v) const override
 
 KoLabColorSpace ()
 
quint8 scaleToU8 (const quint8 *srcPixel, qint32 channelIndex) const override
 
void toHSY (const QVector< double > &channelValues, qreal *hue, qreal *sat, qreal *luma) const override
 
void toQColor (const quint8 *src, QColor *c) const override
 
void toYUV (const QVector< double > &channelValues, qreal *y, qreal *u, qreal *v) const override
 
 ~KoLabColorSpace () override
 
- Public Member Functions inherited from KoSimpleColorSpace< KoLabU16Traits >
KoID colorDepthId () const override
 
void colorFromXML (quint8 *, const QDomElement &) const override
 
KoID colorModelId () const override
 
virtual QString colorSpaceEngine () const
 
virtual quint32 colorSpaceType () const
 
void colorToXML (const quint8 *, QDomDocument &, QDomElement &) const override
 
bool convertPixelsTo (const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const override
 
KoColorTransformationcreateBrightnessContrastAdjustment (const quint16 *) const override
 
KoColorTransformationcreateDarkenAdjustment (qint32, bool, qreal) const override
 
virtual KoColorTransformationcreateDesaturateAdjustment () const
 
KoColorTransformationcreatePerChannelAdjustment (const quint16 *const *) const override
 
quint8 difference (const quint8 *src1, const quint8 *src2) const override
 
quint8 differenceA (const quint8 *src1, const quint8 *src2) const override
 
QVector< double > fromHSY (qreal *, qreal *, qreal *) const override
 
void fromLabA16 (const quint8 *src, quint8 *dst, quint32 nPixels) const override
 
void fromRgbA16 (const quint8 *src, quint8 *dst, quint32 nPixels) const override
 
QVector< double > fromYUV (qreal *, qreal *, qreal *) const override
 
bool hasHighDynamicRange () const override
 
virtual void invertColor (quint8 *, qint32) const
 
 KoSimpleColorSpace (const QString &id, const QString &name, const KoID &colorModelId, const KoID &colorDepthId)
 
const KoColorProfileprofile () const override
 
bool profileIsCompatible (const KoColorProfile *) const override
 
void toHSY (const QVector< double > &, qreal *, qreal *, qreal *) const override
 
void toLabA16 (const quint8 *src, quint8 *dst, quint32 nPixels) const override
 
void toRgbA16 (const quint8 *src, quint8 *dst, quint32 nPixels) const override
 
void toYUV (const QVector< double > &, qreal *, qreal *, qreal *) const override
 
bool willDegrade (ColorSpaceIndependence independence) const override
 
 ~KoSimpleColorSpace () override
 
- Public Member Functions inherited from KoColorSpaceAbstract< _CSTrait >
quint32 alphaPos () const override
 
void applyAlphaNormedFloatMask (quint8 *pixels, const float *alpha, qint32 nPixels) const override
 
void applyAlphaU8Mask (quint8 *pixels, const quint8 *alpha, qint32 nPixels) const override
 
void applyInverseAlphaU8Mask (quint8 *pixels, const quint8 *alpha, qint32 nPixels) const override
 
void applyInverseNormedFloatMask (quint8 *pixels, const float *alpha, qint32 nPixels) const override
 
quint32 channelCount () const override
 
QString channelValueText (const quint8 *pixel, quint32 channelIndex) const override
 
quint32 colorChannelCount () const override
 
void copyOpacityU8 (quint8 *src, quint8 *dst, qint32 nPixels) const override
 
KoColorTransformationcreateInvertTransformation () const override
 
void fillGrayBrushWithColor (quint8 *dst, const QRgb *brush, quint8 *brushColor, qint32 nPixels) const override
 
void fillInverseAlphaNormedFloatMaskWithColor (quint8 *pixels, const float *alpha, const quint8 *brushColor, qint32 nPixels) const override
 
void fromNormalisedChannelsValue (quint8 *pixel, const QVector< float > &values) const override
 
quint8 intensity8 (const quint8 *src) const override
 
qreal intensityF (const quint8 *src) const override
 
 KoColorSpaceAbstract (const QString &id, const QString &name)
 
void multiplyAlpha (quint8 *pixels, quint8 alpha, qint32 nPixels) const override
 
void normalisedChannelsValue (const quint8 *pixel, QVector< float > &channels) const override
 
QString normalisedChannelValueText (const quint8 *pixel, quint32 channelIndex) const override
 
qreal opacityF (const quint8 *U8_pixel) const override
 
quint8 opacityU8 (const quint8 *U8_pixel) const override
 
quint32 pixelSize () const override
 
void setOpacity (quint8 *pixels, qreal alpha, qint32 nPixels) const override
 
void setOpacity (quint8 *pixels, quint8 alpha, qint32 nPixels) const override
 
void singleChannelPixel (quint8 *dstPixel, const quint8 *srcPixel, quint32 channelIndex) const override
 
void toQColor16 (const quint8 *src, QColor *c) const override
 
- Public Member Functions inherited from KoColorSpace
virtual void addCompositeOp (const KoCompositeOp *op)
 
virtual void addDitherOp (KisDitherOp *op)
 
virtual void bitBlt (const KoColorSpace *srcSpace, const KoCompositeOp::ParameterInfo &params, const KoCompositeOp *op, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
 
QBitArray channelFlags (bool color=true, bool alpha=false) const
 
QList< KoChannelInfo * > channels () const
 
const KoCompositeOpcompositeOp (const QString &id, const KoColorSpace *srcSpace=nullptr) const
 
virtual QList< KoCompositeOp * > compositeOps () const
 
virtual QImage convertToQImage (const quint8 *data, qint32 width, qint32 height, const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
 
virtual KoConvolutionOpconvolutionOp () const
 
virtual KoColorConversionTransformationcreateColorConverter (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
 
KoColorTransformationcreateColorTransformation (const QString &id, const QHash< QString, QVariant > &parameters) const
 
virtual KoColorConversionTransformationcreateProofingTransform (const KoColorSpace *dstColorSpace, const KoColorSpace *proofingSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent, bool bpcFirstTransform, quint8 *gamutWarning, KoColorConversionTransformation::ConversionFlags displayConversionFlags) const
 createProofingTransform Create a proofing transform. This is a two part transform that can also do gamut checks. The first transform is from source -> proofing space. Here the gamut checks are performed. The second is the proofing to destination space.
 
virtual void decreaseHue (quint8 *pixel, qreal step) const
 
virtual void decreaseLuminosity (quint8 *pixel, qreal step) const
 
virtual void decreaseSaturation (quint8 *pixel, qreal step) const
 
virtual const KisDitherOpditherOp (const QString &depth, DitherType type) const
 
QPolygonF estimatedTRCXYY () const
 
virtual void fillGrayBrushWithColorAndLightnessOverlay (quint8 *dst, const QRgb *brush, quint8 *brushColor, qint32 nPixels) const
 
virtual void fillGrayBrushWithColorAndLightnessWithStrength (quint8 *dst, const QRgb *brush, quint8 *brushColor, qreal strength, qint32 nPixels) const
 
QPolygonF gamutXYY () const
 
virtual bool hasCompositeOp (const QString &id, const KoColorSpace *srcSpace=nullptr) const
 
QString id () const
 
virtual void increaseBlue (quint8 *pixel, qreal step) const
 
virtual void increaseGreen (quint8 *pixel, qreal step) const
 
virtual void increaseHue (quint8 *pixel, qreal step) const
 
virtual void increaseLuminosity (quint8 *pixel, qreal step) const
 
virtual void increaseRed (quint8 *pixel, qreal step) const
 
virtual void increaseSaturation (quint8 *pixel, qreal step) const
 
virtual void increaseYellow (quint8 *pixel, qreal step) const
 
 KoColorSpace (const QString &id, const QString &name, KoMixColorsOp *mixColorsOp, KoConvolutionOp *convolutionOp)
 Should be called by real color spaces.
 
QVector< qreal > lumaCoefficients () const
 
virtual KoMixColorsOpmixColorsOp () const
 
virtual void modulateLightnessByGrayBrush (quint8 *dst, const QRgb *brush, qreal strength, qint32 nPixels) const
 
QString name () const
 
virtual bool operator== (const KoColorSpace &rhs) const
 
virtual bool proofPixelsTo (const quint8 *src, quint8 *dst, quint32 numPixels, KoColorConversionTransformation *proofingTransform) const
 proofPixelsTo
 
virtual void transparentColor (quint8 *dst, quint32 nPixels) const
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Static Public Member Functions

static QString colorSpaceId ()
 

Static Private Attributes

static const quint32 CHANNEL_A = 1
 
static const quint32 CHANNEL_AB_ZERO_OFFSET = 0x8000
 
static const quint32 CHANNEL_ALPHA = 3
 
static const quint32 CHANNEL_B = 2
 
static const quint32 CHANNEL_L = 0
 
static const quint32 MAX_CHANNEL_AB = 0xffff
 
static const quint32 MAX_CHANNEL_L = 0xff00
 

Additional Inherited Members

- Public Types inherited from KoColorSpaceAbstract< _CSTrait >
typedef _CSTrait ColorSpaceTraits
 
- Public Attributes inherited from KoColorSpace
ThreadLocalCache channelFlagsApplicationCache
 
QList< KoChannelInfo * > channels
 
QVector< qreal > colorants
 
QHash< QString, KoCompositeOp * > compositeOps
 
ThreadLocalCache conversionCache
 
KoConvolutionOpconvolutionOp
 
Deletability deletability
 
QHash< QString, QMap< DitherType, KisDitherOp * > > ditherOps
 
QPolygonF gamutXYY
 
KoColorSpaceEngineiccEngine
 
QString id
 
quint32 idNumber
 
QVector< qreal > lumaCoefficients
 
KoMixColorsOpmixColorsOp
 
QString name
 
KoColorConversionTransformationtransfoFromLABA16
 
KoColorConversionTransformationtransfoFromRGBA16
 
KoColorConversionTransformationtransfoToLABA16
 
KoColorConversionTransformationtransfoToRGBA16
 
QPolygonF TRCXYY
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Member Functions inherited from KoColorSpace
virtual void addChannel (KoChannelInfo *ci)
 
const KoColorConversionTransformationfromLabA16Converter () const
 
const KoColorConversionTransformationfromRgbA16Converter () const
 
 KoColorSpace ()
 Only for use by classes that serve as baseclass for real color spaces.
 
virtual bool preferCompositionInSourceColorSpace () const
 
const KoColorConversionTransformationtoLabA16Converter () const
 
const KoColorConversionTransformationtoRgbA16Converter () const
 
virtual ~KoColorSpace ()
 
- Protected Attributes inherited from KoColorSpace
Private *const d
 

Detailed Description

Basic and simple implementation of the LAB colorspace

Definition at line 21 of file KoLabColorSpace.h.

Constructor & Destructor Documentation

◆ KoLabColorSpace()

KoLabColorSpace::KoLabColorSpace ( )

Definition at line 26 of file KoLabColorSpace.cpp.

26 :
28 i18n("L*a*b* (16-bit integer/channel, unmanaged)"),
31{
32 addChannel(new KoChannelInfo(i18nc("Lightness value in Lab color model", "Lightness"), CHANNEL_L * sizeof(quint16), CHANNEL_L, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(100, 100, 100)));
33 addChannel(new KoChannelInfo(i18n("a*"), CHANNEL_A * sizeof(quint16), CHANNEL_A, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(150, 150, 150)));
34 addChannel(new KoChannelInfo(i18n("b*"), CHANNEL_B * sizeof(quint16), CHANNEL_B, KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(200, 200, 200)));
35 addChannel(new KoChannelInfo(i18n("Alpha"), CHANNEL_ALPHA * sizeof(quint16), CHANNEL_ALPHA, KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16)));
36
37 // ADD, ALPHA_DARKEN, BURN, DIVIDE, DODGE, ERASE, MULTIPLY, OVER, OVERLAY, SCREEN, SUBTRACT
38 addStandardCompositeOps<KoLabU16Traits>(this);
39 addStandardDitherOps<KoLabU16Traits>(this);
40}
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
@ ALPHA
The channel represents the opacity of a pixel.
@ COLOR
The channel represents a color.
@ UINT16
use this for an integer 16bits channel
virtual void addChannel(KoChannelInfo *ci)
static const quint32 CHANNEL_ALPHA
static const quint32 CHANNEL_A
static const quint32 CHANNEL_L
static const quint32 CHANNEL_B
static QString colorSpaceId()

References KoColorSpace::addChannel(), KoChannelInfo::ALPHA, CHANNEL_A, CHANNEL_ALPHA, CHANNEL_B, CHANNEL_L, KoChannelInfo::COLOR, and KoChannelInfo::UINT16.

◆ ~KoLabColorSpace()

KoLabColorSpace::~KoLabColorSpace ( )
override

Definition at line 42 of file KoLabColorSpace.cpp.

43{
44}

Member Function Documentation

◆ clone()

KoColorSpace * KoLabColorSpace::clone ( ) const
virtual

Definition at line 53 of file KoLabColorSpace.cpp.

54{
55 return new KoLabColorSpace();
56}

References KoLabColorSpace().

◆ colorSpaceId()

QString KoLabColorSpace::colorSpaceId ( )
static

Definition at line 47 of file KoLabColorSpace.cpp.

48{
49 return QStringLiteral("LABA");
50}

◆ convertChannelToVisualRepresentation() [1/2]

void KoLabColorSpace::convertChannelToVisualRepresentation ( const quint8 * src,
quint8 * dst,
quint32 nPixels,
const QBitArray selectedChannels ) const
overridevirtual

Convert nPixels pixels in src into their human-visible visual representation. The channels are shown as if other channels were null (or, if Lab, L = 1.0, *a = *b = 0.0).

Both buffers are in the same color space.

Parameters
srcsource buffer in (*this) color space
dstdestination buffer in the same color space as src
nPixelslength of the buffers in number of pixels
pixelSizestride of each pixel in the destination buffer
selectedChannelsBitmap of selected channels

Reimplemented from KoColorSpaceAbstract< _CSTrait >.

Definition at line 246 of file KoLabColorSpace.cpp.

247{
248 for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) {
249 for (uint channelIndex = 0; channelIndex < ColorSpaceTraits::channels_nb; ++channelIndex) {
250
251 if (selectedChannels.testBit(channelIndex)) {
252 ColorSpaceTraits::nativeArray((dst + (pixelIndex * ColorSpaceTraits::pixelSize)))[channelIndex] =
253 ColorSpaceTraits::nativeArray((src + (pixelIndex * ColorSpaceTraits::pixelSize)))[channelIndex];
254 } else {
255 ColorSpaceTraits::channels_type v;
256 switch (channelIndex) {
257 case ColorSpaceTraits::L_pos:
258 v = ColorSpaceTraits::math_trait::halfValueL;
259 break;
260 case ColorSpaceTraits::a_pos:
261 case ColorSpaceTraits::b_pos:
262 v = ColorSpaceTraits::math_trait::halfValueAB;
263 break;
264 default:
265 v = ColorSpaceTraits::math_trait::zeroValue;
266 break;
267 }
268 ColorSpaceTraits::nativeArray((dst + (pixelIndex * ColorSpaceTraits::pixelSize)))[channelIndex] = v;
269 }
270 }
271 }
272}
qreal v
unsigned int uint

References v.

◆ convertChannelToVisualRepresentation() [2/2]

void KoLabColorSpace::convertChannelToVisualRepresentation ( const quint8 * src,
quint8 * dst,
quint32 nPixels,
const qint32 selectedChannelIndex ) const
overridevirtual

Convert nPixels pixels in src into their human-visible visual representation. The channel is shown as grayscale.

Both buffers are in the same color space.

Parameters
srcsource buffer in (*this) color space
dstdestination buffer in the same color space as src
nPixelslength of the buffers in number of pixels
pixelSizestride of each pixel in the destination buffer
selectedChannelIndexIndex of the selected channel.

Reimplemented from KoColorSpaceAbstract< _CSTrait >.

Definition at line 211 of file KoLabColorSpace.cpp.

212{
213 for (uint pixelIndex = 0; pixelIndex < nPixels; ++pixelIndex) {
214 for (uint channelIndex = 0; channelIndex < ColorSpaceTraits::channels_nb; ++channelIndex) {
215 if (channelIndex != ColorSpaceTraits::alpha_pos) {
216 if (channelIndex == ColorSpaceTraits::L_pos) {
217 ColorSpaceTraits::channels_type c = ColorSpaceTraits::nativeArray((src + (pixelIndex * ColorSpaceTraits::pixelSize)))[selectedChannelIndex];
218 switch (selectedChannelIndex) {
219 case ColorSpaceTraits::L_pos:
220 break;
221 case ColorSpaceTraits::a_pos:
222 case ColorSpaceTraits::b_pos:
223 if (c <= ColorSpaceTraits::math_trait::halfValueAB) {
224 c = ColorSpaceTraits::math_trait::unitValueL * (((qreal)c - ColorSpaceTraits::math_trait::zeroValueAB) / (2.0 * (ColorSpaceTraits::math_trait::halfValueAB - ColorSpaceTraits::math_trait::zeroValueAB)));
225 } else {
226 c = ColorSpaceTraits::math_trait::unitValueL * (0.5 + ((qreal)c - ColorSpaceTraits::math_trait::halfValueAB) / (2.0 * (ColorSpaceTraits::math_trait::unitValueAB - ColorSpaceTraits::math_trait::halfValueAB)));
227 }
228 break;
229 // As per KoChannelInfo alpha channels are [0..1]
230 default:
231 c = ColorSpaceTraits::math_trait::unitValueL * (qreal)c / ColorSpaceTraits::math_trait::unitValue;
232 break;
233 }
234 ColorSpaceTraits::nativeArray(dst + (pixelIndex * ColorSpaceTraits::pixelSize))[channelIndex] = c;
235 } else {
236 ColorSpaceTraits::nativeArray(dst + (pixelIndex * ColorSpaceTraits::pixelSize))[channelIndex] = ColorSpaceTraits::math_trait::halfValueAB;
237 }
238 } else {
239 ColorSpaceTraits::nativeArray((dst + (pixelIndex * ColorSpaceTraits::pixelSize)))[channelIndex] =
240 ColorSpaceTraits::nativeArray((src + (pixelIndex * ColorSpaceTraits::pixelSize)))[channelIndex];
241 }
242 }
243 }
244}

◆ fromHSY()

QVector< double > KoLabColorSpace::fromHSY ( qreal * hue,
qreal * sat,
qreal * luma ) const
overridevirtual

Implements KoColorSpace.

Definition at line 162 of file KoLabColorSpace.cpp.

163{
164 QVector <double> channelValues(4);
165 LCHToLab(*luma, *sat, *hue, &channelValues[0],&channelValues[1],&channelValues[2]);
166 channelValues[3]=1.0;
167 return channelValues;
168}
void LCHToLab(const qreal L, const qreal C, const qreal H, qreal *l, qreal *a, qreal *b)

References LCHToLab().

◆ fromQColor()

void KoLabColorSpace::fromQColor ( const QColor & color,
quint8 * dst ) const
overridevirtual

The fromQColor methods take a given color defined as an RGB QColor and fills a byte array with the corresponding color in the the colorspace managed by this strategy.

Parameters
colorthe QColor that will be used to fill dst
dsta pointer to a pixel

Implements KoColorSpace.

Definition at line 58 of file KoLabColorSpace.cpp.

59{
60 // Convert between RGB and CIE-Lab color spaces
61 // Uses ITU-R recommendation BT.709 with D65 as reference white.
62 // algorithm contributed by "Mark A. Ruzon" <ruzon@CS.Stanford.EDU>
63
64 int R, G, B, A;
65 c.getRgb(&R, &G, &B, &A);
66
67 double X, Y, Z, fX, fY, fZ;
68
69 X = 0.412453 * R + 0.357580 * G + 0.180423 * B;
70 Y = 0.212671 * R + 0.715160 * G + 0.072169 * B;
71 Z = 0.019334 * R + 0.119193 * G + 0.950227 * B;
72
73 X /= (255 * 0.950456);
74 Y /= 255;
75 Z /= (255 * 1.088754);
76
77 quint8 L, a, b;
78
79 if (Y > 0.008856) {
80 fY = pow(Y, 1.0 / 3.0);
81 L = static_cast<int>(116.0 * fY - 16.0 + 0.5);
82 } else {
83 fY = 7.787 * Y + 16.0 / 116.0;
84 L = static_cast<int>(903.3 * Y + 0.5);
85 }
86
87 if (X > 0.008856)
88 fX = pow(X, 1.0 / 3.0);
89 else
90 fX = 7.787 * X + 16.0 / 116.0;
91
92 if (Z > 0.008856)
93 fZ = pow(Z, 1.0 / 3.0);
94 else
95 fZ = 7.787 * Z + 16.0 / 116.0;
96
97 a = static_cast<int>(500.0 * (fX - fY) + 0.5);
98 b = static_cast<int>(200.0 * (fY - fZ) + 0.5);
99
100 dst[CHANNEL_L] = UINT8_TO_UINT16(L);
101 dst[CHANNEL_A] = UINT8_TO_UINT16(a);
102 dst[CHANNEL_B] = UINT8_TO_UINT16(b);
104}
Eigen::Matrix< double, 4, 2 > R
uint UINT8_TO_UINT16(uint c)
const QString Y
const QString X

References A, B, CHANNEL_A, CHANNEL_ALPHA, CHANNEL_B, CHANNEL_L, G, R, and UINT8_TO_UINT16().

◆ fromYUV()

QVector< double > KoLabColorSpace::fromYUV ( qreal * y,
qreal * u,
qreal * v ) const
overridevirtual

Implements KoColorSpace.

Definition at line 177 of file KoLabColorSpace.cpp.

178{
179 QVector <double> channelValues(4);
180 channelValues[0]=*y;
181 channelValues[1]=*v;
182 channelValues[2]=*u;
183 channelValues[3]=1.0;
184 return channelValues;
185}
qreal u

References u, and v.

◆ scaleToU8()

quint8 KoLabColorSpace::scaleToU8 ( const quint8 * srcPixel,
qint32 channelPos ) const
overridevirtual

Convert the value of the channel at the specified position into an 8-bit value. The position is not the number of bytes, but the position of the channel as defined in the channel info list.

Reimplemented from KoColorSpaceAbstract< _CSTrait >.

Definition at line 187 of file KoLabColorSpace.cpp.

188{
189 typename ColorSpaceTraits::channels_type c = ColorSpaceTraits::nativeArray(srcPixel)[channelIndex];
190 qreal b = 0;
191 switch (channelIndex) {
192 case ColorSpaceTraits::L_pos:
193 b = ((qreal)c) / ColorSpaceTraits::math_trait::unitValueL;
194 break;
195 case ColorSpaceTraits::a_pos:
196 case ColorSpaceTraits::b_pos:
197 if (c <= ColorSpaceTraits::math_trait::halfValueAB) {
198 b = ((qreal)c - ColorSpaceTraits::math_trait::zeroValueAB) / (2.0 * (ColorSpaceTraits::math_trait::halfValueAB - ColorSpaceTraits::math_trait::zeroValueAB));
199 } else {
200 b = 0.5 + ((qreal)c - ColorSpaceTraits::math_trait::halfValueAB) / (2.0 * (ColorSpaceTraits::math_trait::unitValueAB - ColorSpaceTraits::math_trait::halfValueAB));
201 }
202 break;
203 default:
204 b = ((qreal)c) / ColorSpaceTraits::math_trait::unitValue;
205 break;
206 }
207
209}
static _Tdst scaleToA(_T a)

References KoColorSpaceMaths< _T, _Tdst >::scaleToA().

◆ toHSY()

void KoLabColorSpace::toHSY ( const QVector< double > & channelValues,
qreal * hue,
qreal * sat,
qreal * luma ) const
overridevirtual

Implements KoColorSpace.

Definition at line 157 of file KoLabColorSpace.cpp.

158{
159 LabToLCH(channelValues[0],channelValues[1],channelValues[2], luma, sat, hue);
160}
void LabToLCH(const qreal l, const qreal a, const qreal b, qreal *L, qreal *C, qreal *H)

References LabToLCH().

◆ toQColor()

void KoLabColorSpace::toQColor ( const quint8 * src,
QColor * c ) const
overridevirtual

The toQColor methods take a byte array that is at least pixelSize() long and converts the contents to a QColor, using the given profile as a source profile and the optional profile as a destination profile.

Parameters
srca pointer to the source pixel
cthe QColor that will be filled with the color at src

Implements KoColorSpace.

Definition at line 106 of file KoLabColorSpace.cpp.

107{
108 // Convert between RGB and CIE-Lab color spaces
109 // Uses ITU-R recommendation BT.709 with D65 as reference white.
110 // algorithm contributed by "Mark A. Ruzon" <ruzon@CS.Stanford.EDU>
111 quint8 L, a, b, A;
112 L = UINT16_TO_UINT8(src[CHANNEL_L]);
113 a = UINT16_TO_UINT8(src[CHANNEL_A]);
116
117 double X, Y, Z, fX, fY, fZ;
118 int RR, GG, BB;
119
120 fY = pow((L + 16.0) / 116.0, 3.0);
121 if (fY < 0.008856)
122 fY = L / 903.3;
123 Y = fY;
124
125 if (fY > 0.008856)
126 fY = pow(fY, 1.0 / 3.0);
127 else
128 fY = 7.787 * fY + 16.0 / 116.0;
129
130 fX = a / 500.0 + fY;
131 if (fX > 0.206893)
132 X = pow(fX, 3.0);
133 else
134 X = (fX - 16.0 / 116.0) / 7.787;
135
136 fZ = fY - b / 200.0;
137 if (fZ > 0.206893)
138 Z = pow(fZ, 3.0);
139 else
140 Z = (fZ - 16.0 / 116.0) / 7.787;
141
142 X *= 0.950456 * 255;
143 Y *= 255;
144 Z *= 1.088754 * 255;
145
146 RR = static_cast<int>(3.240479 * X - 1.537150 * Y - 0.498535 * Z + 0.5);
147 GG = static_cast<int>(-0.969256 * X + 1.875992 * Y + 0.041556 * Z + 0.5);
148 BB = static_cast<int>(0.055648 * X - 0.204043 * Y + 1.057311 * Z + 0.5);
149
150 quint8 R = RR < 0 ? 0 : RR > 255 ? 255 : RR;
151 quint8 G = GG < 0 ? 0 : GG > 255 ? 255 : GG;
152 quint8 B = BB < 0 ? 0 : BB > 255 ? 255 : BB;
153
154 c->setRgba(qRgba(R, G, B, A));
155}
uint UINT16_TO_UINT8(uint c)

References A, B, CHANNEL_A, CHANNEL_ALPHA, CHANNEL_B, CHANNEL_L, G, R, and UINT16_TO_UINT8().

◆ toYUV()

void KoLabColorSpace::toYUV ( const QVector< double > & channelValues,
qreal * y,
qreal * u,
qreal * v ) const
overridevirtual

Implements KoColorSpace.

Definition at line 170 of file KoLabColorSpace.cpp.

171{
172 *y =channelValues[0];
173 *v=channelValues[1];
174 *u=channelValues[2];
175}

References u, and v.

Member Data Documentation

◆ CHANNEL_A

const quint32 KoLabColorSpace::CHANNEL_A = 1
staticprivate

Definition at line 49 of file KoLabColorSpace.h.

◆ CHANNEL_AB_ZERO_OFFSET

const quint32 KoLabColorSpace::CHANNEL_AB_ZERO_OFFSET = 0x8000
staticprivate

Definition at line 54 of file KoLabColorSpace.h.

◆ CHANNEL_ALPHA

const quint32 KoLabColorSpace::CHANNEL_ALPHA = 3
staticprivate

Definition at line 51 of file KoLabColorSpace.h.

◆ CHANNEL_B

const quint32 KoLabColorSpace::CHANNEL_B = 2
staticprivate

Definition at line 50 of file KoLabColorSpace.h.

◆ CHANNEL_L

const quint32 KoLabColorSpace::CHANNEL_L = 0
staticprivate

Definition at line 48 of file KoLabColorSpace.h.

◆ MAX_CHANNEL_AB

const quint32 KoLabColorSpace::MAX_CHANNEL_AB = 0xffff
staticprivate

Definition at line 53 of file KoLabColorSpace.h.

◆ MAX_CHANNEL_L

const quint32 KoLabColorSpace::MAX_CHANNEL_L = 0xff00
staticprivate

Definition at line 52 of file KoLabColorSpace.h.


The documentation for this class was generated from the following files: