2
* Copyright (c) 2004-2009 Boudewijn Rempt <boud@valdyas.org>
3
* Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#ifndef KOSIMPLECOLORSPACE_H
20
#define KOSIMPLECOLORSPACE_H
25
#include "DebugPigment.h"
27
#include "KoColorSpaceAbstract.h"
28
#include "KoColorSpaceTraits.h"
29
#include "KoSimpleColorSpaceFactory.h"
30
#include "KoColorModelStandardIds.h"
31
#include "colorprofiles/KoDummyColorProfile.h"
33
template<class _CSTraits>
34
class KoSimpleColorSpace : public KoColorSpaceAbstract<_CSTraits>
39
KoSimpleColorSpace(const QString& id,
41
const KoID& colorModelId,
42
const KoID& colorDepthId)
43
: KoColorSpaceAbstract<_CSTraits>(id, name)
45
, m_colorModelId(colorModelId)
46
, m_colorDepthId(colorDepthId)
47
, m_profile(new KoDummyColorProfile) {
50
virtual ~KoSimpleColorSpace() {
54
virtual KoID colorModelId() const {
55
return m_colorModelId;
58
virtual KoID colorDepthId() const {
59
return m_colorDepthId;
62
virtual bool willDegrade(ColorSpaceIndependence independence) const {
63
Q_UNUSED(independence);
67
virtual bool profileIsCompatible(const KoColorProfile* /*profile*/) const {
71
virtual quint8 difference(const quint8 *src1, const quint8 *src2) const {
74
warnPigment << i18n("Undefined operation in the %1 space").arg(m_name);
78
virtual quint32 colorSpaceType() const {
82
virtual bool hasHighDynamicRange() const {
86
virtual const KoColorProfile* profile() const {
90
virtual KoColorProfile* profile() {
94
virtual KoColorTransformation* createBrightnessContrastAdjustment(const quint16*) const {
95
warnPigment << i18n("Undefined operation in the %1 space").arg(m_name);
99
virtual KoColorTransformation* createDesaturateAdjustment() const {
100
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
104
virtual KoColorTransformation* createPerChannelAdjustment(const quint16* const*) const {
105
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
109
virtual KoColorTransformation *createDarkenAdjustment(qint32 , bool , qreal) const {
110
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
114
virtual void invertColor(quint8*, qint32) const {
115
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
118
virtual void colorToXML(const quint8* , QDomDocument& , QDomElement&) const {
119
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
122
virtual void colorFromXML(quint8* , const QDomElement&) const {
123
warnPigment << i18n("Undefined operation in the %1 color space").arg(m_name);
126
virtual void toLabA16(const quint8* src, quint8* dst, quint32 nPixels) const {
127
if (colorDepthId() == Integer16BitsColorDepthID && colorModelId() == LABAColorModelID) {
128
memcpy(dst, src, nPixels * 2);
130
const KoColorSpace* dstCs = KoColorSpaceRegistry::instance()->lab16();
131
convertPixelsTo(src, dst, dstCs, nPixels);
135
virtual void fromLabA16(const quint8* src, quint8* dst, quint32 nPixels) const {
136
if (colorDepthId() == Integer16BitsColorDepthID && colorModelId() == LABAColorModelID) {
137
memcpy(dst, src, nPixels * 2);
139
const KoColorSpace* srcCs = KoColorSpaceRegistry::instance()->lab16();
140
srcCs->convertPixelsTo(src, dst, this, nPixels);
144
virtual void toRgbA16(const quint8* src, quint8* dst, quint32 nPixels) const {
145
if (colorDepthId() == Integer16BitsColorDepthID && colorModelId() == RGBAColorModelID) {
146
memcpy(dst, src, nPixels * 2);
148
const KoColorSpace* dstCs = KoColorSpaceRegistry::instance()->rgb16();
149
convertPixelsTo(src, dst, dstCs, nPixels);
153
virtual void fromRgbA16(const quint8* src, quint8* dst, quint32 nPixels) const {
154
if (colorDepthId() == Integer16BitsColorDepthID && colorModelId() == RGBAColorModelID) {
155
memcpy(dst, src, nPixels * 2);
157
const KoColorSpace* srcCs = KoColorSpaceRegistry::instance()->rgb16();
158
srcCs->convertPixelsTo(src, dst, this, nPixels);
162
virtual bool convertPixelsTo(const quint8 *src,
163
quint8 *dst, const KoColorSpace * dstColorSpace,
165
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const {
166
Q_UNUSED(renderingIntent);
169
quint32 srcPixelsize = this->pixelSize();
170
quint32 dstPixelsize = dstColorSpace->pixelSize();
172
while (numPixels > 0) {
174
this->toQColor(src, &c);
175
dstColorSpace->fromQColor(c, dst);
186
virtual QString colorSpaceEngine() const {
194
KoColorProfile* m_profile;
199
#endif // KOSIMPLECOLORSPACE_H