7#ifndef _KO_COLORSPACE_TRAITS_H_
8#define _KO_COLORSPACE_TRAITS_H_
38template<
typename _channels_type_,
int _channels_nb_,
int _alpha_pos_>
42 static_assert(_channels_nb_ <=
MAX_CHANNELS_NB,
"MAX_CHANNELS_NB too small");
68 inline static quint8
opacityU8(
const quint8 * U8_pixel) {
74 inline static qreal
opacityF(
const quint8 * U8_pixel) {
83 inline static void setOpacity(quint8 * pixels, quint8 alpha, qint32 nPixels) {
87 for (; nPixels > 0; --nPixels, pixels += psize) {
92 inline static void setOpacity(quint8 * pixels, qreal alpha, qint32 nPixels) {
96 for (; nPixels > 0; --nPixels, pixels += psize) {
104 inline static void copyOpacityU8(quint8* src, quint8* dst, qint32 nPixels) {
107 for (; nPixels > 0; --nPixels, src += psize, dst++) {
131 return new quint8[ nPixels *
pixelSize ];
134 inline static void singleChannelPixel(quint8 *dstPixel,
const quint8 *srcPixel, quint32 channelIndex) {
138 if (i != channelIndex) {
147 if (channelIndex >
channels_nb)
return QString(
"Error");
149 return QString().setNum(c);
153 if (channelIndex >
channels_nb)
return QString(
"Error");
160 return normalisedChannelsValueImpl<channels_type>(pixel,
v);
163 template<typename I, typename std::enable_if_t<std::numeric_limits<I>::is_integer,
int> = 1>
168 float *channels =
v.data();
175 template<typename I, typename std::enable_if_t<!std::numeric_limits<I>::is_integer,
int> = 1>
179 float *channels =
v.data();
187 return fromNormalisedChannelsValueImpl<channels_type>(pixel, values);
190 template<typename I, typename std::enable_if_t<std::numeric_limits<I>::is_integer,
int> = 1>
195 const float *
v = values.data();
206 template<typename I, typename std::enable_if_t<!std::numeric_limits<I>::is_integer,
int> = 1>
210 const float *
v = values.data();
216 inline static void multiplyAlpha(quint8 * pixels, quint8 alpha, qint32 nPixels) {
221 for (; nPixels > 0; --nPixels, pixels +=
pixelSize) {
227 inline static void applyAlphaU8Mask(quint8 * pixels,
const quint8 * alpha, qint32 nPixels) {
230 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++alpha) {
240 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++alpha) {
250 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++alpha) {
260 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++alpha) {
270 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++alpha) {
280 for (; nPixels > 0; --nPixels, pixels +=
pixelSize, ++brush) {
286 for (; nPixels > 0; --nPixels, pixels +=
pixelSize) {
const qreal OPACITY_OPAQUE_F
const quint8 OPACITY_OPAQUE_U8
const int MAX_CHANNELS_NB
const int MAX_CHANNELS_TYPE_SIZE
static _Tdst multiply(_T a, _Tdst b)
static _Tdst scaleToA(_T a)
static const quint32 channels_nb
the number of channels in this color space
static quint8 opacityU8(const quint8 *U8_pixel)
static const qint32 alpha_pos
_channels_type_ channels_type
the type of the value of the channels of this color space
static void fromNormalisedChannelsValue(quint8 *pixel, const QVector< float > &values)
static const channels_type * nativeArray(const quint8 *a)
static QString channelValueText(const quint8 *pixel, quint32 channelIndex)
static void fillInverseAlphaNormedFloatMaskWithColor(quint8 *pixels, const float *alpha, const quint8 *brushColor, qint32 nPixels)
static void multiplyAlpha(quint8 *pixels, quint8 alpha, qint32 nPixels)
static void singleChannelPixel(quint8 *dstPixel, const quint8 *srcPixel, quint32 channelIndex)
static void applyInverseAlphaU8Mask(quint8 *pixels, const quint8 *alpha, qint32 nPixels)
static void normalisedChannelsValueImpl(const quint8 *pixel, QVector< float > &v)
static void applyAlphaU8Mask(quint8 *pixels, const quint8 *alpha, qint32 nPixels)
KoColorSpaceMathsTraits< _channels_type_ > math_trait
the associated math class
static QString normalisedChannelValueText(const quint8 *pixel, quint32 channelIndex)
static const quint32 pixelSize
static void applyInverseAlphaNormedFloatMask(quint8 *pixels, const float *alpha, qint32 nPixels)
static qreal opacityF(const quint8 *U8_pixel)
static void setOpacity(quint8 *pixels, quint8 alpha, qint32 nPixels)
static quint8 * allocate(quint32 nPixels)
static const int depth
the number of bit for each channel
static channels_type * nativeArray(quint8 *a)
static void copyOpacityU8(quint8 *src, quint8 *dst, qint32 nPixels)
static void setOpacity(quint8 *pixels, qreal alpha, qint32 nPixels)
static void normalisedChannelsValue(const quint8 *pixel, QVector< float > &v)
static void fromNormalisedChannelsValueImpl(quint8 *pixel, const QVector< float > &values)
static void fillGrayBrushWithColor(quint8 *pixels, const QRgb *brush, quint8 *brushColor, qint32 nPixels)
static void applyAlphaNormedFloatMask(quint8 *pixels, const float *alpha, qint32 nPixels)