Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSimpleColorSpace.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2004-2009 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7#ifndef KOSIMPLECOLORSPACE_H
8#define KOSIMPLECOLORSPACE_H
9
10#include <QColor>
11
12#include "DebugPigment.h"
13
18
19template<class _CSTraits>
21{
22
23public:
24
25 KoSimpleColorSpace(const QString& id,
26 const QString& name,
27 const KoID& colorModelId,
28 const KoID& colorDepthId)
29 : KoColorSpaceAbstract<_CSTraits>(id, name)
30 , m_name(name)
34 }
35
37 delete m_profile;
38 }
39
40 KoID colorModelId() const override {
41 return m_colorModelId;
42 }
43
44 KoID colorDepthId() const override {
45 return m_colorDepthId;
46 }
47
48 bool willDegrade(ColorSpaceIndependence independence) const override {
49 Q_UNUSED(independence);
50 return false;
51 }
52
53 bool profileIsCompatible(const KoColorProfile* /*profile*/) const override {
54 return true;
55 }
56
57 quint8 difference(const quint8 *src1, const quint8 *src2) const override {
58 Q_UNUSED(src1);
59 Q_UNUSED(src2);
60 warnPigment << i18n("Undefined operation in the %1 space", m_name);
61 return 0;
62 }
63
64 quint8 differenceA(const quint8 *src1, const quint8 *src2) const override {
65 Q_UNUSED(src1);
66 Q_UNUSED(src2);
67 warnPigment << i18n("Undefined operation in the %1 space", m_name);
68 return 0;
69 }
70
71 virtual quint32 colorSpaceType() const {
72 return 0;
73 }
74
75 bool hasHighDynamicRange() const override {
76 return false;
77 }
78
79 const KoColorProfile* profile() const override {
80 return m_profile;
81 }
82
84 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
85 return 0;
86 }
87
89 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
90 return 0;
91 }
92
93 KoColorTransformation* createPerChannelAdjustment(const quint16* const*) const override {
94 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
95 return 0;
96 }
97
98 KoColorTransformation *createDarkenAdjustment(qint32 , bool , qreal) const override {
99 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
100 return 0;
101 }
102
103 virtual void invertColor(quint8*, qint32) const {
104 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
105 }
106
107 void colorToXML(const quint8* , QDomDocument& , QDomElement&) const override {
108 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
109 }
110
111 void colorFromXML(quint8* , const QDomElement&) const override {
112 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
113 }
114 void toHSY(const QVector<double> &, qreal *, qreal *, qreal *) const override {
115 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
116 }
117 QVector <double> fromHSY(qreal *, qreal *, qreal *) const override {
118 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
119 QVector <double> channelValues (2);
120 channelValues.fill(0.0);
121 return channelValues;
122 }
123 void toYUV(const QVector<double> &, qreal *, qreal *, qreal *) const override {
124 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
125 }
126 QVector <double> fromYUV(qreal *, qreal *, qreal *) const override {
127 warnPigment << i18n("Undefined operation in the %1 color space", m_name);
128 QVector <double> channelValues (2);
129 channelValues.fill(0.0);
130 return channelValues;
131 }
132
133 void toLabA16(const quint8* src, quint8* dst, quint32 nPixels) const override {
135 memcpy(dst, src, nPixels * 2);
136 } else {
138 convertPixelsTo(src, dst, dstCs, nPixels,
141 }
142 }
143
144 void fromLabA16(const quint8* src, quint8* dst, quint32 nPixels) const override {
146 memcpy(dst, src, nPixels * 2);
147 } else {
149 srcCs->convertPixelsTo(src, dst, this, nPixels,
152 }
153 }
154
155 void toRgbA16(const quint8* src, quint8* dst, quint32 nPixels) const override {
157 memcpy(dst, src, nPixels * 2);
158 } else {
160 convertPixelsTo(src, dst, dstCs, nPixels,
163 }
164 }
165
166 void fromRgbA16(const quint8* src, quint8* dst, quint32 nPixels) const override {
168 memcpy(dst, src, nPixels * 2);
169 } else {
171 srcCs->convertPixelsTo(src, dst, this, nPixels,
174 }
175 }
176
177 bool convertPixelsTo(const quint8 *src,
178 quint8 *dst, const KoColorSpace * dstColorSpace,
179 quint32 numPixels,
181 KoColorConversionTransformation::ConversionFlags conversionFlags) const override
182 {
183 Q_UNUSED(renderingIntent);
184 Q_UNUSED(conversionFlags);
185
186 QColor c;
187 quint32 srcPixelsize = this->pixelSize();
188 quint32 dstPixelsize = dstColorSpace->pixelSize();
189
190 while (numPixels > 0) {
191
192 this->toQColor(src, &c);
193 dstColorSpace->fromQColor(c, dst);
194
195 src += srcPixelsize;
196 dst += dstPixelsize;
197
198 --numPixels;
199 }
200 return true;
201 }
202
203
204 virtual QString colorSpaceEngine() const {
205 return "simple";
206 }
207
208private:
209 QString m_name;
213
214};
215
216
217#endif // KOSIMPLECOLORSPACE_H
#define warnPigment
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
ColorSpaceIndependence
virtual quint32 pixelSize() const =0
virtual void toQColor(const quint8 *src, QColor *c) const =0
virtual void fromQColor(const QColor &color, quint8 *dst) const =0
virtual bool convertPixelsTo(const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
Definition KoID.h:30
quint8 differenceA(const quint8 *src1, const quint8 *src2) const override
void colorFromXML(quint8 *, const QDomElement &) const override
const KoColorProfile * profile() const override
void fromLabA16(const quint8 *src, quint8 *dst, quint32 nPixels) const override
KoColorTransformation * createBrightnessContrastAdjustment(const quint16 *) const override
QVector< double > fromYUV(qreal *, qreal *, qreal *) const override
KoID colorDepthId() const override
virtual void invertColor(quint8 *, qint32) const
void colorToXML(const quint8 *, QDomDocument &, QDomElement &) const override
virtual quint32 colorSpaceType() const
void toRgbA16(const quint8 *src, quint8 *dst, quint32 nPixels) const override
void toHSY(const QVector< double > &, qreal *, qreal *, qreal *) const override
bool willDegrade(ColorSpaceIndependence independence) const override
QVector< double > fromHSY(qreal *, qreal *, qreal *) const override
KoSimpleColorSpace(const QString &id, const QString &name, const KoID &colorModelId, const KoID &colorDepthId)
KoID colorModelId() const override
KoColorProfile * m_profile
void fromRgbA16(const quint8 *src, quint8 *dst, quint32 nPixels) const override
bool convertPixelsTo(const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const override
virtual KoColorTransformation * createDesaturateAdjustment() const
void toYUV(const QVector< double > &, qreal *, qreal *, qreal *) const override
bool profileIsCompatible(const KoColorProfile *) const override
KoColorTransformation * createPerChannelAdjustment(const quint16 *const *) const override
void toLabA16(const quint8 *src, quint8 *dst, quint32 nPixels) const override
virtual QString colorSpaceEngine() const
quint8 difference(const quint8 *src1, const quint8 *src2) const override
bool hasHighDynamicRange() const override
KoColorTransformation * createDarkenAdjustment(qint32, bool, qreal) const override
const KoColorSpace * lab16(const QString &profileName=QString())
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb16(const QString &profileName=QString())