Krita Source Code Documentation
Loading...
Searching...
No Matches
KoAlphaColorSpaceImpl< _CSTrait > Class Template Reference

#include <KoAlphaColorSpace.h>

+ Inheritance diagram for KoAlphaColorSpaceImpl< _CSTrait >:

Public Member Functions

QString channelValueText (const quint8 *pixel, quint32 channelIndex) const override
 
virtual KoColorSpaceclone () const
 
quint32 colorChannelCount () const override
 
KoID colorDepthId () const override
 
void colorFromXML (quint8 *, const QDomElement &) const override
 
KoID colorModelId () const override
 
virtual quint32 colorSpaceType () const
 
void colorToXML (const quint8 *, QDomDocument &, QDomElement &) const override
 
QImage convertToQImage (const quint8 *data, qint32 width, qint32 height, const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const override
 
virtual void convolveColors (quint8 **colors, qreal *kernelValues, quint8 *dst, qreal factor, qreal offset, qint32 nColors, const QBitArray &channelFlags) const
 
KoColorTransformationcreateBrightnessContrastAdjustment (const quint16 *transferValues) const override
 
KoColorTransformationcreateDarkenAdjustment (qint32, bool, qreal) const override
 
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 fromQColor (const QColor &color, quint8 *dst) 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
 
 KoAlphaColorSpaceImpl ()
 
QString normalisedChannelValueText (const quint8 *pixel, quint32 channelIndex) const override
 
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 toQColor (const quint8 *src, QColor *c) 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
 
 ~KoAlphaColorSpaceImpl () 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 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
 
void copyOpacityU8 (quint8 *src, quint8 *dst, qint32 nPixels) const override
 
KoColorTransformationcreateDarkenAdjustment (qint32 shade, bool compensate, qreal compensation) 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
 
quint8 scaleToU8 (const quint8 *srcPixel, qint32 channelIndex) 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 bool convertPixelsTo (const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, 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 ()
 

Protected Member Functions

bool preferCompositionInSourceColorSpace () const override
 
- 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.
 
const KoColorConversionTransformationtoLabA16Converter () const
 
const KoColorConversionTransformationtoRgbA16Converter () const
 
virtual ~KoColorSpace ()
 

Private Types

typedef KoColorSpaceMaths< channels_type_Maths
 
typedef KoColorSpaceMaths< quint8, channels_type_MathsFromU8
 
typedef KoColorSpaceMaths< channels_type, quint8 > _MathsToU8
 
typedef _CSTrait::channels_type channels_type
 

Private Attributes

KoColorProfilem_profile
 

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 Attributes inherited from KoColorSpace
Private *const d
 

Detailed Description

template<class _CSTrait>
class KoAlphaColorSpaceImpl< _CSTrait >

The alpha mask is a special color strategy that treats all pixels as alpha value with a color common to the mask. The default color is white.

Definition at line 51 of file KoAlphaColorSpace.h.

Member Typedef Documentation

◆ _Maths

template<class _CSTrait >
typedef KoColorSpaceMaths<channels_type> KoAlphaColorSpaceImpl< _CSTrait >::_Maths
private

Definition at line 54 of file KoAlphaColorSpace.h.

◆ _MathsFromU8

template<class _CSTrait >
typedef KoColorSpaceMaths<quint8, channels_type> KoAlphaColorSpaceImpl< _CSTrait >::_MathsFromU8
private

Definition at line 56 of file KoAlphaColorSpace.h.

◆ _MathsToU8

template<class _CSTrait >
typedef KoColorSpaceMaths<channels_type, quint8> KoAlphaColorSpaceImpl< _CSTrait >::_MathsToU8
private

Definition at line 55 of file KoAlphaColorSpace.h.

◆ channels_type

template<class _CSTrait >
typedef _CSTrait::channels_type KoAlphaColorSpaceImpl< _CSTrait >::channels_type
private

Definition at line 53 of file KoAlphaColorSpace.h.

Constructor & Destructor Documentation

◆ KoAlphaColorSpaceImpl()

template<class _CSTrait >
KoAlphaColorSpaceImpl< _CSTrait >::KoAlphaColorSpaceImpl ( )

Definition at line 74 of file KoAlphaColorSpace.cpp.

75 : KoColorSpaceAbstract<_CSTrait>(alphaIdFromChannelType<channels_type>().id(),
76 alphaIdFromChannelType<channels_type>().name())
78{
79 this->addChannel(new KoChannelInfo(i18n("Alpha"), 0, 0, KoChannelInfo::ALPHA, channelInfoIdFromChannelType<channels_type>()));
80
84 this->addCompositeOp(createAlphaDarkenCompositeOp<_CSTrait>(this));
86}
KoColorProfile * m_profile
@ ALPHA
The channel represents the opacity of a pixel.
virtual void addCompositeOp(const KoCompositeOp *op)
virtual void addChannel(KoChannelInfo *ci)

References KoColorSpace::addChannel(), KoColorSpace::addCompositeOp(), and KoChannelInfo::ALPHA.

◆ ~KoAlphaColorSpaceImpl()

template<class _CSTrait >
KoAlphaColorSpaceImpl< _CSTrait >::~KoAlphaColorSpaceImpl ( )
override

Definition at line 89 of file KoAlphaColorSpace.cpp.

90{
91 delete m_profile;
92 m_profile = 0;
93}

Member Function Documentation

◆ channelValueText()

template<class _CSTrait >
QString KoAlphaColorSpaceImpl< _CSTrait >::channelValueText ( const quint8 * pixel,
quint32 channelIndex ) const
overridevirtual

Return a string with the channel's value suitable for display in the gui.

Implements KoColorSpace.

Definition at line 120 of file KoAlphaColorSpace.cpp.

121{
122 Q_ASSERT(channelIndex < this->channelCount());
123 const quint32 channelPosition = this->channels()[channelIndex]->pos();
124 return QString().setNum(_CSTrait::nativeArray(pixel)[channelPosition]);
125}
quint32 channelCount() const override
QList< KoChannelInfo * > channels

◆ clone()

template<class _CSTrait >
KoColorSpace * KoAlphaColorSpaceImpl< _CSTrait >::clone ( ) const
virtual

Definition at line 242 of file KoAlphaColorSpace.cpp.

◆ colorChannelCount()

template<class _CSTrait >
quint32 KoAlphaColorSpaceImpl< _CSTrait >::colorChannelCount ( ) const
inlineoverridevirtual

The total number of color channels (excludes alpha) for a single pixel in this color model.

Implements KoColorSpace.

Definition at line 95 of file KoAlphaColorSpace.h.

95 {
96 return 0;
97 }

◆ colorDepthId()

template<class _CSTrait >
KoID KoAlphaColorSpaceImpl< _CSTrait >::colorDepthId ( ) const
inlineoverridevirtual
Returns
a string that identify the bit depth (for instance "U8" or "F16" ...)
See also
KoColorModelStandardIds.h

Implements KoColorSpace.

Definition at line 73 of file KoAlphaColorSpace.h.

73 {
74 return colorDepthIdForChannelType<channels_type>();
75 }

◆ colorFromXML()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::colorFromXML ( quint8 * pixel,
const QDomElement & elt ) const
inlineoverridevirtual

Unserialize a color following Create's swatch color specification available at https://web.archive.org/web/20110826002520/http://create.freedesktop.org/wiki/Swatches_-_color_file_format/Draft

Parameters
pixelbuffer where the color will be unserialized
eltthe element to unserialize (<CMYK />, <sRGB />, <RGB />)
Returns
the unserialize color, or an empty color object if the function failed to unserialize the color

Implements KoColorSpace.

Definition at line 152 of file KoAlphaColorSpace.h.

152 {
153 warnPigment << i18n("Undefined operation in the alpha color space");
154 }
#define warnPigment

References warnPigment.

◆ colorModelId()

template<class _CSTrait >
KoID KoAlphaColorSpaceImpl< _CSTrait >::colorModelId ( ) const
inlineoverridevirtual
Returns
a string that identify the color model (for instance "RGB" or "CMYK" ...)
See also
KoColorModelStandardIds.h

Implements KoColorSpace.

Definition at line 69 of file KoAlphaColorSpace.h.

69 {
70 return AlphaColorModelID;
71 }
const KoID AlphaColorModelID("A", ki18n("Alpha mask"))

References AlphaColorModelID.

◆ colorSpaceId()

template<class _CSTrait >
static QString KoAlphaColorSpaceImpl< _CSTrait >::colorSpaceId ( )
inlinestatic

Definition at line 65 of file KoAlphaColorSpace.h.

65 {
66 return alphaIdFromChannelType<channels_type>().id();
67 }

◆ colorSpaceType()

template<class _CSTrait >
virtual quint32 KoAlphaColorSpaceImpl< _CSTrait >::colorSpaceType ( ) const
inlinevirtual

Definition at line 105 of file KoAlphaColorSpace.h.

105 {
106 return 0;
107 }

◆ colorToXML()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::colorToXML ( const quint8 * pixel,
QDomDocument & doc,
QDomElement & colorElt ) const
inlineoverridevirtual

Serialize this color following Create's swatch color specification available at https://web.archive.org/web/20110826002520/http://create.freedesktop.org/wiki/Swatches_-_color_file_format/Draft

This function doesn't create the <color /> element but rather the <CMYK />, <sRGB />, <RGB /> ... elements. It is assumed that colorElt is the <color /> element.

Parameters
pixelbuffer to serialized
colorEltroot element for the serialization, it is assumed that this element is <color />
docis the document containing colorElt

Implements KoColorSpace.

Definition at line 148 of file KoAlphaColorSpace.h.

148 {
149 warnPigment << i18n("Undefined operation in the alpha color space");
150 }

References warnPigment.

◆ convertToQImage()

template<class _CSTrait >
QImage KoAlphaColorSpaceImpl< _CSTrait >::convertToQImage ( const quint8 * data,
qint32 width,
qint32 height,
const KoColorProfile * dstProfile,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags ) const
overridevirtual

Convert the pixels in data to (8-bit BGRA) QImage using the specified profiles.

Parameters
dataA pointer to a contiguous memory region containing width * height pixels
widthin pixels
heightin pixels
dstProfiledestination profile
renderingIntentthe rendering intent
conversionFlagsconversion flags

Reimplemented from KoColorSpace.

Definition at line 156 of file KoAlphaColorSpace.cpp.

160{
161 const channels_type *srcPtr = _CSTrait::nativeArray(data);
162
163 QImage img(width, height, QImage::Format_Indexed8);
164 QVector<QRgb> table;
165 for (int i = 0; i < 256; ++i) table.append(qRgb(i, i, i));
166 img.setColorTable(table);
167
168 quint8* data_img;
169 for (int i = 0; i < height; ++i) {
170 data_img = img.scanLine(i);
171
172 for (int j = 0; j < width; ++j) {
173 data_img[j] = _MathsToU8::scaleToA(*(srcPtr++));
174 }
175 }
176
177 return img;
178}
_CSTrait::channels_type channels_type
static _Tdst scaleToA(_T a)

◆ convolveColors()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::convolveColors ( quint8 ** colors,
qreal * kernelValues,
quint8 * dst,
qreal factor,
qreal offset,
qint32 nColors,
const QBitArray & channelFlags ) const
virtual

Definition at line 136 of file KoAlphaColorSpace.cpp.

137{
138 qreal totalAlpha = 0;
139
140 while (nColors--) {
141 qreal weight = *kernelValues;
142
143 if (weight != 0) {
144 totalAlpha += _CSTrait::nativeArray(*colors)[0] * weight;
145 }
146 ++colors;
147 ++kernelValues;
148 }
149
150 if (channelFlags.isEmpty() || channelFlags.testBit(0)) {
151 _CSTrait::nativeArray(dst)[0] = _Maths::clamp((totalAlpha / factor) + offset);
152 }
153}
static dst_compositetype clamp(dst_compositetype val)
QBitArray channelFlags(bool color=true, bool alpha=false) const

◆ createBrightnessContrastAdjustment()

template<class _CSTrait >
KoColorTransformation * KoAlphaColorSpaceImpl< _CSTrait >::createBrightnessContrastAdjustment ( const quint16 * transferValues) const
inlineoverridevirtual

Create an adjustment object for adjusting the brightness and contrast transferValues is a 256 bins array with values from 0 to 0xFFFF This function is thread-safe, but you need to create one KoColorTransformation per thread.

Implements KoColorSpace.

Definition at line 128 of file KoAlphaColorSpace.h.

128 {
129 Q_UNUSED(transferValues);
130 warnPigment << i18n("Undefined operation in the alpha color space");
131 return 0;
132 }

References warnPigment.

◆ createDarkenAdjustment()

template<class _CSTrait >
KoColorTransformation * KoAlphaColorSpaceImpl< _CSTrait >::createDarkenAdjustment ( qint32 shade,
bool compensate,
qreal compensation ) const
inlineoverridevirtual

Darken all color channels with the given amount. If compensate is true, the compensation factor will be used to limit the darkening.

Implements KoColorSpace.

Definition at line 139 of file KoAlphaColorSpace.h.

139 {
140 warnPigment << i18n("Undefined operation in the alpha color space");
141 return 0;
142 }

References warnPigment.

◆ createPerChannelAdjustment()

template<class _CSTrait >
KoColorTransformation * KoAlphaColorSpaceImpl< _CSTrait >::createPerChannelAdjustment ( const quint16 *const * transferValues) const
inlineoverridevirtual

Create an adjustment object for adjusting individual channels transferValues is an array of colorChannelCount number of 256 bins array with values from 0 to 0xFFFF This function is thread-safe, but you need to create one KoColorTransformation per thread.

The layout of the channels must be the following:

0..N-2 - color channels of the pixel; N-1 - alpha channel of the pixel (if exists)

Implements KoColorSpace.

Definition at line 134 of file KoAlphaColorSpace.h.

134 {
135 warnPigment << i18n("Undefined operation in the alpha color space");
136 return 0;
137 }

References warnPigment.

◆ difference()

template<class _CSTrait >
quint8 KoAlphaColorSpaceImpl< _CSTrait >::difference ( const quint8 * src1,
const quint8 * src2 ) const
overridevirtual

Get the difference between 2 colors, normalized in the range (0,255). Only completely opaque and completely transparent are taken into account when computing the difference; other transparency levels are not regarded when finding the difference.

Completely transparent pixels are treated as if they are completely different from any non-transparent pixels.

Implements KoColorSpace.

Definition at line 108 of file KoAlphaColorSpace.cpp.

109{
110 return qAbs(_MathsToU8::scaleToA(_CSTrait::nativeArray(src2)[0] - _CSTrait::nativeArray(src1)[0]));
111}

◆ differenceA()

template<class _CSTrait >
quint8 KoAlphaColorSpaceImpl< _CSTrait >::differenceA ( const quint8 * src1,
const quint8 * src2 ) const
overridevirtual

Get the difference between 2 colors, normalized in the range (0,255). This function takes the Alpha channel of the pixel into account. Alpha channel has the same weight as Lightness channel.

Completely transparent pixels are treated as if their color channels are the same as ones of the other pixel. In other words, only alpha channel difference is compared.

Implements KoColorSpace.

Definition at line 114 of file KoAlphaColorSpace.cpp.

115{
116 return difference(src1, src2);
117}
quint8 difference(const quint8 *src1, const quint8 *src2) const override

◆ fromHSY()

template<class _CSTrait >
QVector< double > KoAlphaColorSpaceImpl< _CSTrait >::fromHSY ( qreal * ,
qreal * ,
qreal *  ) const
inlineoverridevirtual

Implements KoColorSpace.

Definition at line 160 of file KoAlphaColorSpace.h.

160 {
161 warnPigment << i18n("Undefined operation in the alpha color space");
162 QVector <double> channelValues (1);
163 channelValues.fill(0.0);
164 return channelValues;
165 }

References warnPigment.

◆ fromLabA16()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::fromLabA16 ( const quint8 * src,
quint8 * dst,
quint32 nPixels ) const
overridevirtual

Convert the specified data from Lab (D50). to this colorspace. All colorspaces are guaranteed to support this.

Parameters
srcthe pixels in 16 bit lab format
dstthe destination data
nPixelsthe number of pixels in the array

Reimplemented from KoColorSpace.

Definition at line 197 of file KoAlphaColorSpace.cpp.

197 {
198 const quint16* srcPtr = reinterpret_cast<const quint16*>(src);
199 channels_type* dstPtr = _CSTrait::nativeArray(dst);
200
201 while (nPixels--) {
202 dstPtr[0] = KoColorSpaceMaths<quint16, channels_type>::scaleToA(UINT16_MULT(srcPtr[0], srcPtr[3]));
203
204 dstPtr++;
205 srcPtr += 4;
206 }
207}
uint UINT16_MULT(uint a, uint b)

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

◆ fromQColor()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::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 96 of file KoAlphaColorSpace.cpp.

97{
98 _CSTrait::nativeArray(dst)[0] = _MathsFromU8::scaleToA(c.alpha());
99}

◆ fromRgbA16()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::fromRgbA16 ( const quint8 * src,
quint8 * dst,
quint32 nPixels ) const
overridevirtual

Convert the specified data from sRGB 16 bits. to this colorspace. All colorspaces are guaranteed to support this.

Parameters
srcthe pixels in 16 bit rgb format
dstthe destination data
nPixelsthe number of pixels in the array

Reimplemented from KoColorSpace.

Definition at line 228 of file KoAlphaColorSpace.cpp.

228 {
229 const quint16* srcPtr = reinterpret_cast<const quint16*>(src);
230 channels_type* dstPtr = _CSTrait::nativeArray(dst);
231
232 while (nPixels--) {
233 // WARNING: we consider red channel only!
234 dstPtr[0] = KoColorSpaceMaths<quint16, channels_type>::scaleToA(UINT16_MULT(srcPtr[0], srcPtr[3]));
235
236 dstPtr++;
237 srcPtr += 4;
238 }
239}

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

◆ fromYUV()

template<class _CSTrait >
QVector< double > KoAlphaColorSpaceImpl< _CSTrait >::fromYUV ( qreal * ,
qreal * ,
qreal *  ) const
inlineoverridevirtual

Implements KoColorSpace.

Definition at line 171 of file KoAlphaColorSpace.h.

171 {
172 warnPigment << i18n("Undefined operation in the alpha color space");
173 QVector <double> channelValues (1);
174 channelValues.fill(0.0);
175 return channelValues;
176 }

References warnPigment.

◆ hasHighDynamicRange()

template<class _CSTrait >
bool KoAlphaColorSpaceImpl< _CSTrait >::hasHighDynamicRange ( ) const
inlineoverridevirtual

Returns true if the colorspace supports channel values outside the (normalised) range 0 to 1.

Implements KoColorSpace.

Definition at line 109 of file KoAlphaColorSpace.h.

109 {
110 return false;
111 }

◆ invertColor()

template<class _CSTrait >
virtual void KoAlphaColorSpaceImpl< _CSTrait >::invertColor ( quint8 * ,
qint32  ) const
inlinevirtual

Definition at line 144 of file KoAlphaColorSpace.h.

144 {
145 warnPigment << i18n("Undefined operation in the alpha color space");
146 }

References warnPigment.

◆ normalisedChannelValueText()

template<class _CSTrait >
QString KoAlphaColorSpaceImpl< _CSTrait >::normalisedChannelValueText ( const quint8 * pixel,
quint32 channelIndex ) const
overridevirtual

Return a string with the channel's value with integer channels normalised to the floating point range 0 to 1, if appropriate.

Implements KoColorSpace.

Definition at line 128 of file KoAlphaColorSpace.cpp.

129{
130 Q_ASSERT(channelIndex < this->channelCount());
131 const quint32 channelPosition = this->channels()[channelIndex]->pos();
132 return QString().setNum(KoColorSpaceMaths<channels_type, float>::scaleToA(_CSTrait::nativeArray(pixel)[channelPosition]));
133}

◆ preferCompositionInSourceColorSpace()

template<class _CSTrait >
bool KoAlphaColorSpaceImpl< _CSTrait >::preferCompositionInSourceColorSpace ( ) const
overrideprotectedvirtual

This function defines the behavior of the bitBlt function when the composition of pixels in different colorspaces is requested, that is in case:

srcCS == any dstCS == this

1) preferCompositionInSourceColorSpace() == false,

the source pixels are first converted to *this color space and then composition is performed.

2) preferCompositionInSourceColorSpace() == true,

the destination pixels are first converted into *srcCS color space, then the composition is done, and the result is finally converted into *this colorspace.

This is used by alpha8() color space mostly, because it has weaker representation of the color, so the composition should be done in CS with richer functionality.

Reimplemented from KoColorSpace.

Definition at line 248 of file KoAlphaColorSpace.cpp.

249{
250 return true;
251}

◆ profile()

template<class _CSTrait >
const KoColorProfile * KoAlphaColorSpaceImpl< _CSTrait >::profile ( ) const
inlineoverridevirtual

Return the profile of this color space.

Implements KoColorSpace.

Definition at line 113 of file KoAlphaColorSpace.h.

113 {
114 return m_profile;
115 }

◆ profileIsCompatible()

template<class _CSTrait >
bool KoAlphaColorSpaceImpl< _CSTrait >::profileIsCompatible ( const KoColorProfile * profile) const
inlineoverridevirtual
Returns
true if the profile given in argument can be used by this color space

Implements KoColorSpace.

Definition at line 84 of file KoAlphaColorSpace.h.

84 {
85 return false;
86 }

◆ toHSY()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::toHSY ( const QVector< double > & ,
qreal * ,
qreal * ,
qreal *  ) const
inlineoverridevirtual

Implements KoColorSpace.

Definition at line 156 of file KoAlphaColorSpace.h.

156 {
157 warnPigment << i18n("Undefined operation in the alpha color space");
158 }

References warnPigment.

◆ toLabA16()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::toLabA16 ( const quint8 * src,
quint8 * dst,
quint32 nPixels ) const
overridevirtual

Convert the specified data to Lab (D50). All colorspaces are guaranteed to support this

Parameters
srcthe source data
dstthe destination data
nPixelsthe number of source pixels

Reimplemented from KoColorSpace.

Definition at line 181 of file KoAlphaColorSpace.cpp.

181 {
182 const channels_type* srcPtr = _CSTrait::nativeArray(src);
183 quint16* dstPtr = reinterpret_cast<quint16*>(dst);
184
185 while (nPixels--) {
187 dstPtr[1] = UINT16_MAX / 2;
188 dstPtr[2] = UINT16_MAX / 2;
189 dstPtr[3] = UINT16_MAX;
190
191 srcPtr++;
192 dstPtr += 4;
193 }
194}
#define UINT16_MAX

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

◆ toQColor()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::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 102 of file KoAlphaColorSpace.cpp.

103{
104 c->setRgba(qRgba(255, 255, 255, _MathsToU8::scaleToA(_CSTrait::nativeArray(src)[0])));
105}

◆ toRgbA16()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::toRgbA16 ( const quint8 * src,
quint8 * dst,
quint32 nPixels ) const
overridevirtual

Convert the specified data to sRGB 16 bits. All colorspaces are guaranteed to support this

Parameters
srcthe source data
dstthe destination data
nPixelsthe number of source pixels

Reimplemented from KoColorSpace.

Definition at line 210 of file KoAlphaColorSpace.cpp.

210 {
211 const channels_type* srcPtr = _CSTrait::nativeArray(src);
212 quint16* dstPtr = reinterpret_cast<quint16*>(dst);
213
214 while (nPixels--) {
215 const quint16 gray = KoColorSpaceMaths<channels_type, quint16>::scaleToA(srcPtr[0]);
216
217 dstPtr[0] = gray;
218 dstPtr[1] = gray;
219 dstPtr[2] = gray;
220 dstPtr[3] = UINT16_MAX;
221
222 srcPtr++;
223 dstPtr += 4;
224 }
225}

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

◆ toYUV()

template<class _CSTrait >
void KoAlphaColorSpaceImpl< _CSTrait >::toYUV ( const QVector< double > & ,
qreal * ,
qreal * ,
qreal *  ) const
inlineoverridevirtual

Implements KoColorSpace.

Definition at line 167 of file KoAlphaColorSpace.h.

167 {
168 warnPigment << i18n("Undefined operation in the alpha color space");
169 }

References warnPigment.

◆ willDegrade()

template<class _CSTrait >
bool KoAlphaColorSpaceImpl< _CSTrait >::willDegrade ( ColorSpaceIndependence independence) const
inlineoverridevirtual

If false, images in this colorspace will degrade considerably by functions, tools and filters that have the given measure of colorspace independence.

Parameters
independencethe measure to which this colorspace will suffer from the manipulations of the tool or filter asking
Returns
false if no degradation will take place, true if degradation will take place

Implements KoColorSpace.

Definition at line 79 of file KoAlphaColorSpace.h.

79 {
80 Q_UNUSED(independence);
81 return false;
82 }

Member Data Documentation

◆ m_profile

template<class _CSTrait >
KoColorProfile* KoAlphaColorSpaceImpl< _CSTrait >::m_profile
private

Definition at line 182 of file KoAlphaColorSpace.h.


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