Commit 8cfdfe4e authored by Cyrille Berger's avatar Cyrille Berger

d-pointerification of KoColorSpace

svn path=/trunk/koffice/; revision=625077
parent 020e36d5
......@@ -31,10 +31,10 @@
KisGrayU16ColorSpace ::KisGrayU16ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<GrayU16Traits>("GRAYU16", i18n("Grayscale 16-bit integer/channel)"), parent, TYPE_GRAY_16, icSigGrayData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16));
addChannel(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<GrayU16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<GrayU16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<GrayU16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<GrayU16Traits>( this ) );
}
......@@ -31,10 +31,10 @@
KisGrayColorSpace ::KisGrayColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<GrayU8Traits>("GRAYU8", i18n("Grayscale 8-bit integer/channel)"), parent, TYPE_GRAY_8, icSigGrayData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
addChannel(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<GrayU8Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<GrayU8Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<GrayU8Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<GrayU8Traits>( this ) );
}
......@@ -51,10 +51,10 @@ KisLmsF32ColorSpace::KisLmsF32ColorSpace(KoColorSpaceRegistry * parent, KoColorP
, KoF32ColorSpaceTrait(PIXEL_ALPHA * sizeof(float))
, KoLcmsColorSpaceTrait(F32_LCMS_TYPE, icSig3colorData, 0)
{
m_channels.push_back(new KoChannelInfo(i18n("Long"), PIXEL_LONGWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KoChannelInfo(i18n("Middle"), PIXEL_MIDDLEWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KoChannelInfo(i18n("Short"), PIXEL_SHORTWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(float), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32, sizeof(float)));
addChannel(new KoChannelInfo(i18n("Long"), PIXEL_LONGWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
addChannel(new KoChannelInfo(i18n("Middle"), PIXEL_MIDDLEWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
addChannel(new KoChannelInfo(i18n("Short"), PIXEL_SHORTWAVE * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float)));
addChannel(new KoChannelInfo(i18n("Alpha"), PIXEL_ALPHA * sizeof(float), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32, sizeof(float)));
}
KisLmsF32ColorSpace::~KisLmsF32ColorSpace()
......
......@@ -35,11 +35,11 @@
KisRgbF16HDRColorSpace::KisRgbF16HDRColorSpace(KoColorSpaceRegistry * parent, KoColorProfile */*p*/)
: KisRgbFloatHDRColorSpace<RgbF16Traits>("RGBAF16HALF", i18n("RGB (16-bit float/channel) for High Dynamic Range imaging"), parent, RGBAF16HALF_LCMS_TYPE)
{
m_channels.push_back(new KoChannelInfo(i18n("Red"), 2 * sizeof(half), KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(255,0,0)));
m_channels.push_back(new KoChannelInfo(i18n("Green"), 1 * sizeof(half), KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(0,255,0)));
m_channels.push_back(new KoChannelInfo(i18n("Blue"), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(0,0,255)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(half), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT16));
addChannel(new KoChannelInfo(i18n("Red"), 2 * sizeof(half), KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(255,0,0)));
addChannel(new KoChannelInfo(i18n("Green"), 1 * sizeof(half), KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(0,255,0)));
addChannel(new KoChannelInfo(i18n("Blue"), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT16, sizeof(half), QColor(0,0,255)));
addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(half), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT16));
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<RgbF16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<RgbF16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<RgbF16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<RgbF16Traits>( this ) );
}
......@@ -37,11 +37,11 @@
KisRgbF32HDRColorSpace::KisRgbF32HDRColorSpace(KoColorSpaceRegistry * parent, KoColorProfile */*p*/)
: KisRgbFloatHDRColorSpace<RgbF32Traits>("RGBAF32", i18n("RGB (32-bit float/channel) for High Dynamic Range imaging"), parent, RGBAF32FLOAT_LCMS_TYPE)
{
m_channels.push_back(new KoChannelInfo(i18n("Red"), 2 * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float), QColor(255,0,0)));
m_channels.push_back(new KoChannelInfo(i18n("Green"), 1 * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float), QColor(0,255,0)));
m_channels.push_back(new KoChannelInfo(i18n("Blue"), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(double), QColor(0,0,255)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(float), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32));
addChannel(new KoChannelInfo(i18n("Red"), 2 * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float), QColor(255,0,0)));
addChannel(new KoChannelInfo(i18n("Green"), 1 * sizeof(float), KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(float), QColor(0,255,0)));
addChannel(new KoChannelInfo(i18n("Blue"), 0, KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, sizeof(double), QColor(0,0,255)));
addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(float), KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32));
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<RgbF32Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<RgbF32Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<RgbF32Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<RgbF32Traits>( this ) );
}
......@@ -24,19 +24,46 @@
#include "KoCompositeOp.h"
#include "KoColorTransformation.h"
KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoColorSpaceRegistry * parent)
: m_id(id)
, m_name( name )
, m_parent( parent )
, m_mixColorsOp( 0 )
, m_convolutionOp( 0 )
struct KoColorSpace::Private {
QString id;
QString name;
QHash<QString, KoCompositeOp *> compositeOps;
KoColorSpaceRegistry * parent;
Q3ValueVector<KoChannelInfo *> channels;
KoMixColorsOp* mixColorsOp;
KoConvolutionOp* convolutionOp;
mutable Q3MemArray<quint8> conversionCache; // XXX: This will be a bad problem when we have threading.
};
KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoColorSpaceRegistry * parent, KoMixColorsOp* mixColorsOp, KoConvolutionOp* convolutionOp )
: d (new Private())
{
//m_dcop = 0;
d->id = id;
d->name = name;
d->parent = parent;
d->mixColorsOp = mixColorsOp;
d->convolutionOp = convolutionOp;
}
KoColorSpace::~KoColorSpace()
{
//delete m_dcop;
delete d->mixColorsOp;
delete d->convolutionOp;
delete d;
}
QString KoColorSpace::id() const {return d->id;}
QString KoColorSpace::name() const {return d->name;}
Q3ValueVector<KoChannelInfo *> KoColorSpace::channels() const
{
return d->channels;
}
void KoColorSpace::addChannel(KoChannelInfo * ci)
{
d->channels.push_back(ci);
}
quint8 *KoColorSpace::allocPixelBuffer(quint32 numPixels) const
......@@ -46,21 +73,41 @@ quint8 *KoColorSpace::allocPixelBuffer(quint32 numPixels) const
QList<KoCompositeOp*> KoColorSpace::userVisiblecompositeOps() const
{
return m_compositeOps.values();
return d->compositeOps.values();
}
void KoColorSpace::mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const
{
Q_ASSERT(d->mixColorsOp);
d->mixColorsOp->mixColors(colors, weights, nColors, dst);
}
KoMixColorsOp* KoColorSpace::mixColorsOp() const {
return d->mixColorsOp;
}
void KoColorSpace::convolveColors(quint8** colors, qint32* kernelValues, KoChannelInfo::enumChannelFlags channelFlags, quint8 *dst, qint32 factor, qint32 offset, qint32 nPixels) const
{
Q_ASSERT(d->convolutionOp);
d->convolutionOp->convolveColors(colors, kernelValues, channelFlags, dst, factor, offset, nPixels);
}
KoConvolutionOp* KoColorSpace::convolutionOp() const {
return d->convolutionOp;
}
const KoCompositeOp * KoColorSpace::compositeOp(const QString & id) const
{
if ( m_compositeOps.contains( id ) )
return m_compositeOps.value( id );
if ( d->compositeOps.contains( id ) )
return d->compositeOps.value( id );
else
return m_compositeOps.value( COMPOSITE_OVER );
return d->compositeOps.value( COMPOSITE_OVER );
}
void KoColorSpace::addCompositeOp(const KoCompositeOp * op)
{
if ( op->colorSpace()->id() == id()) {
m_compositeOps.insert( op->id(), const_cast<KoCompositeOp*>( op ) );
d->compositeOps.insert( op->id(), const_cast<KoCompositeOp*>( op ) );
}
}
......@@ -95,11 +142,11 @@ void KoColorSpace::bitBlt(quint8 *dst,
const QString & op,
const QBitArray & channelFlags) const
{
if ( m_compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( op ), channelFlags);
if ( d->compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ), channelFlags);
}
else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( COMPOSITE_OVER ), channelFlags);
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ), channelFlags);
}
}
......@@ -116,11 +163,11 @@ void KoColorSpace::bitBlt(quint8 *dst,
qint32 cols,
const QString& op) const
{
if ( m_compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( op ));
if ( d->compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( op ));
}
else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( COMPOSITE_OVER ) );
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, d->compositeOps.value( COMPOSITE_OVER ) );
}
}
......@@ -144,7 +191,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
quint32 len = pixelSize() * rows * cols;
// If our conversion cache is too small, extend it.
if (!m_conversionCache.resize( len, Q3GArray::SpeedOptim )) {
if (!d->conversionCache.resize( len, Q3GArray::SpeedOptim )) {
kWarning() << "Could not allocate enough memory for the conversion!\n";
// XXX: We should do a slow, pixel by pixel bitblt here...
abort();
......@@ -152,7 +199,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
for (qint32 row = 0; row < rows; row++) {
srcSpace->convertPixelsTo(src + row * srcRowStride,
m_conversionCache.data() + row * cols * pixelSize(), this,
d->conversionCache.data() + row * cols * pixelSize(), this,
cols);
}
......@@ -160,7 +207,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
srcRowStride = cols * pixelSize();
op->composite( dst, dststride,
m_conversionCache.data(), srcRowStride,
d->conversionCache.data(), srcRowStride,
srcAlphaMask, maskRowStride,
rows, cols,
opacity, channelFlags );
......@@ -197,7 +244,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
quint32 len = pixelSize() * rows * cols;
// If our conversion cache is too small, extend it.
if (!m_conversionCache.resize( len, Q3GArray::SpeedOptim )) {
if (!d->conversionCache.resize( len, Q3GArray::SpeedOptim )) {
kWarning() << "Could not allocate enough memory for the conversion!\n";
// XXX: We should do a slow, pixel by pixel bitblt here...
abort();
......@@ -205,7 +252,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
for (qint32 row = 0; row < rows; row++) {
srcSpace->convertPixelsTo(src + row * srcRowStride,
m_conversionCache.data() + row * cols * pixelSize(), this,
d->conversionCache.data() + row * cols * pixelSize(), this,
cols);
}
......@@ -213,7 +260,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
srcRowStride = cols * pixelSize();
op->composite( dst, dststride,
m_conversionCache.data(), srcRowStride,
d->conversionCache.data(), srcRowStride,
srcAlphaMask, maskRowStride,
rows, cols,
opacity);
......
/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
* Copyright (c) 2006-2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -125,7 +125,7 @@ protected:
public:
/// Should be called by real color spaces
KoColorSpace(const QString &id, const QString &name, KoColorSpaceRegistry * parent);
KoColorSpace(const QString &id, const QString &name, KoColorSpaceRegistry * parent, KoMixColorsOp* mixColorsOp, KoConvolutionOp* convolutionOp );
virtual ~KoColorSpace();
virtual bool operator==(const KoColorSpace& rhs) const {
......@@ -138,10 +138,7 @@ public:
//========== Channels =====================================================//
/// Return a vector describing all the channels this color model has.
virtual Q3ValueVector<KoChannelInfo *> channels() const
{
return m_channels;
}
virtual Q3ValueVector<KoChannelInfo *> channels() const;
/**
* The total number of channels for a single pixel in this color model
......@@ -202,12 +199,12 @@ public:
/**
* ID for use in files and internally: unchanging name
*/
virtual QString id() const {return m_id;};
virtual QString id() const;
/**
* i18n name.
*/
virtual QString name() const {return m_name;};
virtual QString name() const;
/**
* lcms colorspace type definition.
......@@ -473,34 +470,23 @@ public:
/**
* Mix the colors given their weights and return in dst
* The sum of weights is assumed 255 */
inline KDE_DEPRECATED void mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const
{
Q_ASSERT(m_mixColorsOp);
m_mixColorsOp->mixColors(colors, weights, nColors, dst);
}
KDE_DEPRECATED void mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const;
/**
* @return the mix color operation of this colorspace (do not delete it locally, it's deleted by the colorspace).
*/
inline KoMixColorsOp* mixColorsOp() const {
return m_mixColorsOp;
}
virtual KoMixColorsOp* mixColorsOp() const;
/**
* Convolve the given array of pointers to pixels and return the result
* in dst. The kernel values are clamped between -128 and 128
*/
inline KDE_DEPRECATED void convolveColors(quint8** colors, qint32* kernelValues, KoChannelInfo::enumChannelFlags channelFlags, quint8 *dst, qint32 factor, qint32 offset, qint32 nPixels) const
{
Q_ASSERT(m_convolutionOp);
m_convolutionOp->convolveColors(colors, kernelValues, channelFlags, dst, factor, offset, nPixels);
}
KDE_DEPRECATED void convolveColors(quint8** colors, qint32* kernelValues, KoChannelInfo::enumChannelFlags channelFlags, quint8 *dst, qint32 factor, qint32 offset, qint32 nPixels) const;
/**
* @return the convolution operation of this colorspace (do not delete it locally, it's deleted by the colorspace).
*/
inline KoConvolutionOp* convolutionOp() const {
return m_convolutionOp;
}
virtual KoConvolutionOp* convolutionOp() const;
/**
* Calculate the intensity of the given pixel, scaled down to the range 0-255. XXX: Maybe this should be more flexible
......@@ -599,19 +585,15 @@ public:
*/
virtual Q3ValueList<KisFilter*> createBackgroundFilters() const
{ return Q3ValueList<KisFilter*>(); };
private:
QString m_id;
QString m_name;
protected:
KoColorSpaceRegistry * m_parent;
Q3ValueVector<KoChannelInfo *> m_channels;
QHash<QString, KoCompositeOp *> m_compositeOps;
mutable Q3MemArray<quint8> m_conversionCache; // XXX: This will be a bad problem when we have threading.
KoMixColorsOp* m_mixColorsOp;
KoConvolutionOp* m_convolutionOp;
/**
* Use this function in the constructor of your colorspace to add the information about a channel.
* @param ci a pointer to the information about a channel
*/
virtual void addChannel(KoChannelInfo * ci);
private:
class Private;
Private* d;
};
class KoColorSpaceFactory {
......
......@@ -36,7 +36,7 @@ namespace {
public:
explicit CompositeCopy(KoColorSpace * cs)
: KoCompositeOp(cs, COMPOSITE_OVER, i18n("Copy" ) )
: KoCompositeOp(cs, COMPOSITE_COPY, i18n("Copy" ) )
{
}
......@@ -197,10 +197,12 @@ template<class _CSTraits>
class KoColorSpaceAbstract : public KoColorSpace {
public:
KoColorSpaceAbstract(const QString &id, const QString &name, KoColorSpaceRegistry * parent, DWORD cmType,
icColorSpaceSignature colorSpaceSignature) : KoColorSpace(id, name, parent), m_cmType(cmType), m_colorSpaceSignature(colorSpaceSignature) {
this->m_compositeOps.insert( COMPOSITE_COPY, new CompositeCopy( this ) );
m_mixColorsOp = new KoMixColorsOpImpl< _CSTraits>();
m_convolutionOp = new KoConvolutionOpImpl< _CSTraits>();
icColorSpaceSignature colorSpaceSignature ) :
KoColorSpace(id, name, parent, new KoMixColorsOpImpl< _CSTraits>(), new KoConvolutionOpImpl< _CSTraits>()),
m_cmType(cmType),
m_colorSpaceSignature(colorSpaceSignature)
{
this->addCompositeOp( new CompositeCopy( this ) );
};
virtual void setColorSpaceType(quint32 type) { m_cmType = type; }
......
......@@ -229,10 +229,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
KoColorSpace * dstCS;
if (dstProfile)
dstCS = this->m_parent->colorSpace("RGBA", dstProfile);
else
dstCS = this->m_parent->rgb8();
dstCS = KoColorSpaceRegistry::instance()->colorSpace("RGBA", dstProfile);
if (data)
convertPixelsTo(const_cast<quint8 *>(data), img.bits(), dstCS, width * height, renderingIntent);
......
......@@ -268,11 +268,11 @@ namespace {
KoAlphaColorSpace::KoAlphaColorSpace(KoColorSpaceRegistry * parent) :
KoColorSpaceAbstract<AlphaU8Traits>("ALPHA", i18n("Alpha mask"), parent, TYPE_GRAY_8, icSigGrayData )
{
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 0, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
m_compositeOps.insert( COMPOSITE_OVER, new CompositeOver( this ) );
m_compositeOps.insert( COMPOSITE_CLEAR, new CompositeClear( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new CompositeErase( this ) );
m_compositeOps.insert( COMPOSITE_SUBTRACT, new CompositeSubtract( this ) );
addChannel(new KoChannelInfo(i18n("Alpha"), 0, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
addCompositeOp( new CompositeOver( this ) );
addCompositeOp( new CompositeClear( this ) );
addCompositeOp( new CompositeErase( this ) );
addCompositeOp( new CompositeSubtract( this ) );
}
KoAlphaColorSpace::~KoAlphaColorSpace()
......@@ -353,7 +353,7 @@ bool KoAlphaColorSpace::convertPixelsTo(const quint8 *src,
QString KoAlphaColorSpace::channelValueText(const quint8 *pixel, quint32 channelIndex) const
{
Q_ASSERT(channelIndex < channelCount());
quint32 channelPosition = m_channels[channelIndex]->pos();
quint32 channelPosition = channels()[channelIndex]->pos();
return QString().setNum(pixel[channelPosition]);
}
......@@ -361,7 +361,7 @@ QString KoAlphaColorSpace::channelValueText(const quint8 *pixel, quint32 channel
QString KoAlphaColorSpace::normalisedChannelValueText(const quint8 *pixel, quint32 channelIndex) const
{
Q_ASSERT(channelIndex < channelCount());
quint32 channelPosition = m_channels[channelIndex]->pos();
quint32 channelPosition = channels()[channelIndex]->pos();
return QString().setNum(static_cast<float>(pixel[channelPosition]) / UINT8_MAX);
}
......
......@@ -29,13 +29,13 @@
KoLabColorSpace::KoLabColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<KoLabU16Traits>("LABA", i18n("L*a*b* (16-bit integer/channel)"), parent, COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1), icSigLabData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Lightness"), CHANNEL_L * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(100,100,100)));
m_channels.push_back(new KoChannelInfo(i18n("a*"), CHANNEL_A * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(150,150,150)));
m_channels.push_back(new KoChannelInfo(i18n("b*"), CHANNEL_B * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(200,200,200)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), CHANNEL_ALPHA * sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16)));
addChannel(new KoChannelInfo(i18n("Lightness"), CHANNEL_L * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(100,100,100)));
addChannel(new KoChannelInfo(i18n("a*"), CHANNEL_A * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(150,150,150)));
addChannel(new KoChannelInfo(i18n("b*"), CHANNEL_B * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), QColor(200,200,200)));
addChannel(new KoChannelInfo(i18n("Alpha"), CHANNEL_ALPHA * sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16)));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<KoLabU16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<KoLabU16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<KoLabU16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<KoLabU16Traits>( this ) );
}
bool KoLabColorSpace::willDegrade(ColorSpaceIndependence independence) const
......
......@@ -29,13 +29,13 @@
KoRgbU16ColorSpace::KoRgbU16ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<KoRgbU16Traits>("RGBU16", i18n("RGB 16-bit integer/channel)"), parent, TYPE_BGRA_16, icSigRgbData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Red"), 2* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(255,0,0)));
m_channels.push_back(new KoChannelInfo(i18n("Green"), 1* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(0,255,0)));
m_channels.push_back(new KoChannelInfo(i18n("Blue"), 0* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(0,0,255)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 3* sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16));
addChannel(new KoChannelInfo(i18n("Red"), 2* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(255,0,0)));
addChannel(new KoChannelInfo(i18n("Green"), 1* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(0,255,0)));
addChannel(new KoChannelInfo(i18n("Blue"), 0* sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, 4, QColor(0,0,255)));
addChannel(new KoChannelInfo(i18n("Alpha"), 3* sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<KoRgbU16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<KoRgbU16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<KoRgbU16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<KoRgbU16Traits>( this ) );
}
bool KoRgbU16ColorSpace::willDegrade(ColorSpaceIndependence independence) const
......
......@@ -29,14 +29,14 @@
KisCmykU16ColorSpace::KisCmykU16ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<CmykU16Traits>("CMYKA16", i18n("CMYK (16-bit integer/channel)"), parent, TYPE_CMYK5_16, icSigCmykData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Cyan"), 0 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::cyan));
m_channels.push_back(new KoChannelInfo(i18n("Magenta"), 1 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::magenta));
m_channels.push_back(new KoChannelInfo(i18n("Yellow"), 2 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::yellow));
m_channels.push_back(new KoChannelInfo(i18n("Black"), 3 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::black));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 4 * sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16)));
addChannel(new KoChannelInfo(i18n("Cyan"), 0 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::cyan));
addChannel(new KoChannelInfo(i18n("Magenta"), 1 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::magenta));
addChannel(new KoChannelInfo(i18n("Yellow"), 2 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::yellow));
addChannel(new KoChannelInfo(i18n("Black"), 3 * sizeof(quint16), KoChannelInfo::COLOR, KoChannelInfo::UINT16, sizeof(quint16), Qt::black));
addChannel(new KoChannelInfo(i18n("Alpha"), 4 * sizeof(quint16), KoChannelInfo::ALPHA, KoChannelInfo::UINT16, sizeof(quint16)));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<CmykU16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<CmykU16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<CmykU16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<CmykU16Traits>( this ) );
}
bool KisCmykU16ColorSpace::willDegrade(ColorSpaceIndependence independence) const
......
......@@ -29,14 +29,14 @@
KisCmykU8ColorSpace::KisCmykU8ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<CmykU8Traits>("CMYK", i18n("CMYK (8-bit integer/channel)"), parent, TYPE_CMYK5_8, icSigCmykData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Cyan"), 0 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::cyan));
m_channels.push_back(new KoChannelInfo(i18n("Magenta"), 1 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::magenta));
m_channels.push_back(new KoChannelInfo(i18n("Yellow"), 2 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::yellow));
m_channels.push_back(new KoChannelInfo(i18n("Black"), 3 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::black));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 4 * sizeof(quint8), KoChannelInfo::ALPHA, KoChannelInfo::UINT8, sizeof(quint8)));
addChannel(new KoChannelInfo(i18n("Cyan"), 0 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::cyan));
addChannel(new KoChannelInfo(i18n("Magenta"), 1 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::magenta));
addChannel(new KoChannelInfo(i18n("Yellow"), 2 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::yellow));
addChannel(new KoChannelInfo(i18n("Black"), 3 * sizeof(quint8), KoChannelInfo::COLOR, KoChannelInfo::UINT8, sizeof(quint8), Qt::black));
addChannel(new KoChannelInfo(i18n("Alpha"), 4 * sizeof(quint8), KoChannelInfo::ALPHA, KoChannelInfo::UINT8, sizeof(quint8)));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<CmykU8Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<CmykU8Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<CmykU8Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<CmykU8Traits>( this ) );
}
bool KisCmykU8ColorSpace::willDegrade(ColorSpaceIndependence independence) const
......
......@@ -31,11 +31,11 @@
KisGrayAU16ColorSpace ::KisGrayAU16ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<GrayAU16Traits>("GRAYA16", i18n("Grayscale 16-bit integer/channel)"), parent, TYPE_GRAYA_16, icSigGrayData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT16));
addChannel(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT16));
addChannel(new KoChannelInfo(i18n("Alpha"), 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT16));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<GrayAU16Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<GrayAU16Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<GrayAU16Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<GrayAU16Traits>( this ) );
}
......@@ -31,11 +31,11 @@
KisGrayAU8ColorSpace ::KisGrayAU8ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<GrayAU8Traits>("GRAYA", i18n("Grayscale 8-bit integer/channel)"), parent, TYPE_GRAYA_8, icSigGrayData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
addChannel(new KoChannelInfo(i18n("Gray"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8));
addChannel(new KoChannelInfo(i18n("Alpha"), 1, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
init();
m_compositeOps.insert( COMPOSITE_OVER, new KoCompositeOpOver<GrayAU8Traits>( this ) );
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<GrayAU8Traits>( this ) );
addCompositeOp( new KoCompositeOpOver<GrayAU8Traits>( this ) );
addCompositeOp( new KoCompositeOpErase<GrayAU8Traits>( this ) );
}
......@@ -40,25 +40,25 @@
KisRgbColorSpace ::KisRgbColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p) :
KoLcmsColorSpace<RgbU8Traits>("RGBA", i18n("RGB 8-bit integer/channel)"), parent, TYPE_BGRA_8, icSigRgbData, p)
{
m_channels.push_back(new KoChannelInfo(i18n("Red"), 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(255,0,0)));
m_channels.push_back(new KoChannelInfo(i18n("Green"), 1, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0,255,0)));
m_channels.push_back(new KoChannelInfo(i18n("Blue"), 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0,0,255)));
m_channels.push_back(new KoChannelInfo(i18n("Alpha"), 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT8));
addChannel(new