Commit 06291f6c authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make pigmentcms conform to the koffice libs coding standards

svn path=/trunk/koffice/; revision=1069460
parent 42288bce
This diff is collapsed.
......@@ -31,31 +31,49 @@
#include "pigment_export.h"
#include "KoColorSpaceRegistry.h"
class PIGMENTCMS_EXPORT KoBasicHistogramProducer : public KoHistogramProducer {
class PIGMENTCMS_EXPORT KoBasicHistogramProducer : public KoHistogramProducer
{
public:
KoBasicHistogramProducer(const KoID& id, int channels, int nrOfBins, const KoColorSpace *colorSpace);
virtual ~KoBasicHistogramProducer() {}
virtual void clear();
virtual void setView(qreal from, qreal size) { m_from = from; m_width = size; }
virtual void setView(qreal from, qreal size) {
m_from = from; m_width = size;
}
virtual const KoID& id() const { return m_id; }
virtual QList<KoChannelInfo *> channels() { return m_colorSpace->channels(); }
virtual qint32 numberOfBins() { return m_nrOfBins; }
virtual qreal viewFrom() const { return m_from; }
virtual qreal viewWidth() const { return m_width; }
virtual const KoID& id() const {
return m_id;
}
virtual QList<KoChannelInfo *> channels() {
return m_colorSpace->channels();
}
virtual qint32 numberOfBins() {
return m_nrOfBins;
}
virtual qreal viewFrom() const {
return m_from;
}
virtual qreal viewWidth() const {
return m_width;
}
virtual qint32 count() { return m_count; }
virtual qint32 count() {
return m_count;
}
virtual qint32 getBinAt(int channel, int position)
{ return m_bins.at(externalToInternal(channel)).at(position); }
virtual qint32 getBinAt(int channel, int position) {
return m_bins.at(externalToInternal(channel)).at(position);
}
virtual qint32 outOfViewLeft(int channel)
{ return m_outLeft.at(externalToInternal(channel)); }
virtual qint32 outOfViewLeft(int channel) {
return m_outLeft.at(externalToInternal(channel));
}
virtual qint32 outOfViewRight(int channel)
{ return m_outRight.at(externalToInternal(channel)); }
virtual qint32 outOfViewRight(int channel) {
return m_outRight.at(externalToInternal(channel));
}
protected:
/**
......@@ -83,15 +101,19 @@ protected:
QVector<qint32> m_external;
};
class PIGMENTCMS_EXPORT KoBasicU8HistogramProducer : public KoBasicHistogramProducer {
class PIGMENTCMS_EXPORT KoBasicU8HistogramProducer : public KoBasicHistogramProducer
{
public:
KoBasicU8HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
virtual QString positionToString(qreal pos) const;
virtual qreal maximalZoom() const { return 1.0; }
virtual qreal maximalZoom() const {
return 1.0;
}
};
class PIGMENTCMS_EXPORT KoBasicU16HistogramProducer : public KoBasicHistogramProducer {
class PIGMENTCMS_EXPORT KoBasicU16HistogramProducer : public KoBasicHistogramProducer
{
public:
KoBasicU16HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
......@@ -99,7 +121,8 @@ public:
virtual qreal maximalZoom() const;
};
class PIGMENTCMS_EXPORT KoBasicF32HistogramProducer : public KoBasicHistogramProducer {
class PIGMENTCMS_EXPORT KoBasicF32HistogramProducer : public KoBasicHistogramProducer
{
public:
KoBasicF32HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
......@@ -109,7 +132,8 @@ public:
#ifdef HAVE_OPENEXR
class PIGMENTCMS_EXPORT KoBasicF16HalfHistogramProducer : public KoBasicHistogramProducer {
class PIGMENTCMS_EXPORT KoBasicF16HalfHistogramProducer : public KoBasicHistogramProducer
{
public:
KoBasicF16HalfHistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
......@@ -124,16 +148,22 @@ public:
* Factories with Producers in the code because they are incompatible types, and
* in the GUI we actually only need a producer's name, not a factory's.
*/
template<class T> class KoBasicHistogramProducerFactory : public KoHistogramProducerFactory {
template<class T> class KoBasicHistogramProducerFactory : public KoHistogramProducerFactory
{
public:
KoBasicHistogramProducerFactory(const KoID& id, const QString& csId)
: KoHistogramProducerFactory(id), m_csId(csId)
{
: KoHistogramProducerFactory(id), m_csId(csId) {
}
virtual ~KoBasicHistogramProducerFactory() {}
virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new T(KoID(id(), name()), KoColorSpaceRegistry::instance()->colorSpace(m_csId, 0))); }
virtual bool isCompatibleWith(const KoColorSpace* colorSpace) const { return colorSpace->id() == m_csId; }
virtual float preferrednessLevelWith(const KoColorSpace* /*colorSpace*/) const { return 1.0; }
virtual KoHistogramProducerSP generate() {
return KoHistogramProducerSP(new T(KoID(id(), name()), KoColorSpaceRegistry::instance()->colorSpace(m_csId, 0)));
}
virtual bool isCompatibleWith(const KoColorSpace* colorSpace) const {
return colorSpace->id() == m_csId;
}
virtual float preferrednessLevelWith(const KoColorSpace* /*colorSpace*/) const {
return 1.0;
}
protected:
QString m_csId;
};
......@@ -144,7 +174,8 @@ protected:
* Registry, because it isCompatibleWith all colorspaces, and should only be used in extreme
* cases (like no other producer being available
**/
class PIGMENTCMS_EXPORT KoGenericRGBHistogramProducer : public KoBasicHistogramProducer {
class PIGMENTCMS_EXPORT KoGenericRGBHistogramProducer : public KoBasicHistogramProducer
{
public:
KoGenericRGBHistogramProducer();
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
......@@ -156,14 +187,21 @@ protected:
};
/** KoGenericRGBHistogramProducer his special Factory that isCompatibleWith everything. */
class PIGMENTCMS_EXPORT KoGenericRGBHistogramProducerFactory : public KoHistogramProducerFactory {
class PIGMENTCMS_EXPORT KoGenericRGBHistogramProducerFactory : public KoHistogramProducerFactory
{
public:
KoGenericRGBHistogramProducerFactory()
: KoHistogramProducerFactory(KoID("GENRGBHISTO", i18n("Generic RGB Histogram"))) {}
: KoHistogramProducerFactory(KoID("GENRGBHISTO", i18n("Generic RGB Histogram"))) {}
virtual ~KoGenericRGBHistogramProducerFactory() {}
virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new KoGenericRGBHistogramProducer()); }
virtual bool isCompatibleWith(const KoColorSpace*) const { return true; }
virtual float preferrednessLevelWith(const KoColorSpace*) const { return 0.0; }
virtual KoHistogramProducerSP generate() {
return KoHistogramProducerSP(new KoGenericRGBHistogramProducer());
}
virtual bool isCompatibleWith(const KoColorSpace*) const {
return true;
}
virtual float preferrednessLevelWith(const KoColorSpace*) const {
return 0.0;
}
};
......@@ -172,27 +210,35 @@ public:
* to L*a*b*, and then does its counting.
* It isCompatibleWith all colorspaces
**/
class PIGMENTCMS_EXPORT KoGenericLabHistogramProducer : public KoBasicHistogramProducer {
public:
KoGenericLabHistogramProducer();
virtual ~KoGenericLabHistogramProducer();
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
virtual QString positionToString(qreal pos) const;
virtual qreal maximalZoom() const;
virtual QList<KoChannelInfo *> channels();
protected:
QList<KoChannelInfo *> m_channelsList;
class PIGMENTCMS_EXPORT KoGenericLabHistogramProducer : public KoBasicHistogramProducer
{
public:
KoGenericLabHistogramProducer();
virtual ~KoGenericLabHistogramProducer();
virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace);
virtual QString positionToString(qreal pos) const;
virtual qreal maximalZoom() const;
virtual QList<KoChannelInfo *> channels();
protected:
QList<KoChannelInfo *> m_channelsList;
};
/** KoGenericLabHistogramProducer his special Factory that isCompatibleWith everything. */
class /*PIGMENTCMS_EXPORT*/ KoGenericLabHistogramProducerFactory : public KoHistogramProducerFactory {
public:
KoGenericLabHistogramProducerFactory()
: KoHistogramProducerFactory(KoID("GENLABHISTO", i18n("Generic L*a*b* Histogram"))) {}
virtual ~KoGenericLabHistogramProducerFactory() {}
virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new KoGenericLabHistogramProducer()); }
virtual bool isCompatibleWith(const KoColorSpace*) const { return true; }
virtual float preferrednessLevelWith(const KoColorSpace*) const { return 0.0; }
class /*PIGMENTCMS_EXPORT*/ KoGenericLabHistogramProducerFactory : public KoHistogramProducerFactory
{
public:
KoGenericLabHistogramProducerFactory()
: KoHistogramProducerFactory(KoID("GENLABHISTO", i18n("Generic L*a*b* Histogram"))) {}
virtual ~KoGenericLabHistogramProducerFactory() {}
virtual KoHistogramProducerSP generate() {
return KoHistogramProducerSP(new KoGenericLabHistogramProducer());
}
virtual bool isCompatibleWith(const KoColorSpace*) const {
return true;
}
virtual float preferrednessLevelWith(const KoColorSpace*) const {
return 0.0;
}
};
......
......@@ -27,7 +27,8 @@
* that is, one of the components that makes up a particular
* pixel.
*/
class KoChannelInfo {
class KoChannelInfo
{
public:
/// enum to define the type of the channel
enum enumChannelType {
......@@ -59,45 +60,56 @@ public:
* @param size number of bytes (not bits) of the channel
* @param color a color to represent that channel (for instance in an histogram)
*/
KoChannelInfo( const QString & name, qint32 npos, enumChannelType channelType, enumChannelValueType channelValueType, qint32 size = 1, QColor color = QColor(0,0,0))
: m_name (name), m_pos (npos), m_channelType(channelType), m_channelValueType(channelValueType), m_size(size), m_color(color) { }
KoChannelInfo(const QString & name, qint32 npos, enumChannelType channelType, enumChannelValueType channelValueType, qint32 size = 1, QColor color = QColor(0, 0, 0))
: m_name(name), m_pos(npos), m_channelType(channelType), m_channelValueType(channelValueType), m_size(size), m_color(color) { }
public:
/**
* User-friendly name for this channel for presentation purposes in the gui
*/
inline QString name() const { return m_name; }
inline QString name() const {
return m_name;
}
/**
* returns the position of the first byte of the channel in the pixel
*/
inline qint32 pos() const { return m_pos; }
inline qint32 pos() const {
return m_pos;
}
/**
* returns the number of bytes this channel takes
*/
inline qint32 size() const { return m_size; }
inline qint32 size() const {
return m_size;
}
/**
* returns the type of the channel
*/
inline enumChannelType channelType() const { return m_channelType; }
inline enumChannelType channelType() const {
return m_channelType;
}
/**
* return the type of the value of the channel (float, uint8 or uint16)
*/
inline enumChannelValueType channelValueType() const { return m_channelValueType; }
inline enumChannelValueType channelValueType() const {
return m_channelValueType;
}
/**
* This is a color that can be used to represent this channel in histograms and so.
* By default this is black, so keep in mind that many channels might look the same
*/
inline QColor color() const { return m_color; }
inline QColor color() const {
return m_color;
}
/**
* A channel is less than another channel if its pos is smaller.
*/
inline bool operator<( const KoChannelInfo & info )
{
return m_pos < info.m_pos;
}
inline bool operator<(const KoChannelInfo & info) {
return m_pos < info.m_pos;
}
private:
......
......@@ -32,7 +32,8 @@
#include "KoColorSpaceRegistry.h"
class KoColor::Private {
class KoColor::Private
{
public:
Private() : data(0), colorSpace(0) {}
......@@ -45,7 +46,7 @@ public:
};
KoColor::KoColor()
: d(new Private())
: d(new Private())
{
d->colorSpace = KoColorSpaceRegistry::instance()->lab16(0);
d->data = new quint8[d->colorSpace->pixelSize()];
......@@ -54,7 +55,7 @@ KoColor::KoColor()
}
KoColor::KoColor(const KoColorSpace * colorSpace)
: d(new Private())
: d(new Private())
{
Q_ASSERT(colorSpace);
d->colorSpace = KoColorSpaceRegistry::instance()->permanentColorspace(colorSpace);
......@@ -69,7 +70,7 @@ KoColor::~KoColor()
}
KoColor::KoColor(const QColor & color, const KoColorSpace * colorSpace)
: d(new Private())
: d(new Private())
{
Q_ASSERT(color.isValid());
Q_ASSERT(colorSpace);
......@@ -82,7 +83,7 @@ KoColor::KoColor(const QColor & color, const KoColorSpace * colorSpace)
}
KoColor::KoColor(const quint8 * data, const KoColorSpace * colorSpace)
: d(new Private())
: d(new Private())
{
Q_ASSERT(colorSpace);
Q_ASSERT(data);
......@@ -94,7 +95,7 @@ KoColor::KoColor(const quint8 * data, const KoColorSpace * colorSpace)
KoColor::KoColor(const KoColor &src, const KoColorSpace * colorSpace)
: d(new Private())
: d(new Private())
{
Q_ASSERT(colorSpace);
d->colorSpace = KoColorSpaceRegistry::instance()->permanentColorspace(colorSpace);
......@@ -105,12 +106,11 @@ KoColor::KoColor(const KoColor &src, const KoColorSpace * colorSpace)
}
KoColor::KoColor(const KoColor & rhs)
: d(new Private())
: d(new Private())
{
d->colorSpace = rhs.colorSpace();
Q_ASSERT(*d->colorSpace == *KoColorSpaceRegistry::instance()->permanentColorspace(d->colorSpace));
if(d->colorSpace && rhs.d->data)
{
if (d->colorSpace && rhs.d->data) {
d->data = new quint8[d->colorSpace->pixelSize()];
memcpy(d->data, rhs.d->data, d->colorSpace->pixelSize());
}
......@@ -200,19 +200,16 @@ void KoColor::dump() const
QList<KoChannelInfo *>::const_iterator begin = channels.constBegin();
QList<KoChannelInfo *>::const_iterator end = channels.constEnd();
for (QList<KoChannelInfo *>::const_iterator it = begin; it != end; ++it)
{
for (QList<KoChannelInfo *>::const_iterator it = begin; it != end; ++it) {
KoChannelInfo * ch = (*it);
// XXX: setNum always takes a byte.
if (ch->size() == sizeof(quint8)) {
// Byte
//dbgPigment <<"Channel (byte):" << ch->name() <<":" << QString().setNum(d->data[ch->pos()]) <<"";
}
else if (ch->size() == sizeof(quint16)) {
} else if (ch->size() == sizeof(quint16)) {
// Short (may also by an nvidia half)
//dbgPigment <<"Channel (short):" << ch->name() <<":" << QString().setNum(*((const quint16 *)(d->data+ch->pos()))) <<"";
}
else if (ch->size() == sizeof(quint32)) {
} else if (ch->size() == sizeof(quint32)) {
// Integer (may also be float... Find out how to distinguish these!)
//dbgPigment <<"Channel (int):" << ch->name() <<":" << QString().setNum(*((const quint32 *)(d->data+ch->pos()))) <<"";
}
......@@ -230,78 +227,74 @@ const KoColorProfile * KoColor::profile() const
return d->colorSpace->profile();
}
quint8 * KoColor::data() {
quint8 * KoColor::data()
{
return d->data;
}
const quint8 * KoColor::data() const {
const quint8 * KoColor::data() const
{
return d->data;
}
const KoColorSpace * KoColor::colorSpace() const {
const KoColorSpace * KoColor::colorSpace() const
{
return d->colorSpace;
}
void KoColor::toXML(QDomDocument& doc, QDomElement& colorElt) const
{
d->colorSpace->colorToXML( d->data, doc, colorElt);
d->colorSpace->colorToXML(d->data, doc, colorElt);
}
void KoColor::setOpacity(quint8 alpha )
void KoColor::setOpacity(quint8 alpha)
{
d->colorSpace->setAlpha( d->data, alpha, 1);
d->colorSpace->setAlpha(d->data, alpha, 1);
}
quint8 KoColor::opacity() const
{
return d->colorSpace->alpha( d->data );
return d->colorSpace->alpha(d->data);
}
KoColor KoColor::fromXML(const QDomElement& elt, const QString & bitDepthId, const QHash<QString, QString> & aliases)
{
QString modelId;
if(elt.tagName() == "CMYK")
{
if (elt.tagName() == "CMYK") {
modelId = CMYKAColorModelID.id();
} else if( elt.tagName() == "RGB") {
} else if (elt.tagName() == "RGB") {
modelId = RGBAColorModelID.id();
} else if( elt.tagName() == "sRGB") {
} else if (elt.tagName() == "sRGB") {
modelId = RGBAColorModelID.id();
} else if( elt.tagName() == "Lab") {
} else if (elt.tagName() == "Lab") {
modelId = LABAColorModelID.id();
} else if( elt.tagName() == "XYZ") {
} else if (elt.tagName() == "XYZ") {
modelId = XYZAColorModelID.id();
} else if( elt.tagName() == "Gray") {
} else if (elt.tagName() == "Gray") {
modelId = GrayAColorModelID.id();
} else if( elt.tagName() == "YCbCr") {
} else if (elt.tagName() == "YCbCr") {
modelId = YCbCrAColorModelID.id();
}
QString profileName;
if( elt.tagName() != "sRGB")
{
profileName = elt.attribute("space","");
if( aliases.contains(profileName))
{
if (elt.tagName() != "sRGB") {
profileName = elt.attribute("space", "");
if (aliases.contains(profileName)) {
profileName = aliases.value(profileName);
}
if( !KoColorSpaceRegistry::instance()->profileByName( profileName))
{
if (!KoColorSpaceRegistry::instance()->profileByName(profileName)) {
profileName = "";
}
}
QString csId = KoColorSpaceRegistry::instance()->colorSpaceId(modelId, bitDepthId);
if(csId.isEmpty())
{
QList<KoID> list = KoColorSpaceRegistry::instance()->colorDepthList(modelId, KoColorSpaceRegistry::AllColorSpaces );
if(!list.empty())
{
if (csId.isEmpty()) {
QList<KoID> list = KoColorSpaceRegistry::instance()->colorDepthList(modelId, KoColorSpaceRegistry::AllColorSpaces);
if (!list.empty()) {
csId = KoColorSpaceRegistry::instance()->colorSpaceId(modelId, list[0].id());
}
}
const KoColorSpace* cs = KoColorSpaceRegistry::instance()->colorSpace(csId, profileName);
if(cs)
{
if (cs) {
KoColor c(cs);
cs->colorFromXML( c.data(), elt);
cs->colorFromXML(c.data(), elt);
return c;
} else {
return KoColor();
......
......@@ -34,7 +34,8 @@ class KoColorSpace;
* A KoColor describes a color in a certain colorspace. The color is stored in a buffer
* that can be manipulated by the function of the color space.
*/
class PIGMENTCMS_EXPORT KoColor {
class PIGMENTCMS_EXPORT KoColor
{
public:
/// Create an empty KoColor. It will be valid, but also black and transparent
......@@ -91,7 +92,7 @@ public:
/**
* Convenient function to set the opacity of the color.
*/
void setOpacity(quint8 alpha );
void setOpacity(quint8 alpha);
/**
* Convenient function that return the opacity of the color
*/
......@@ -155,6 +156,6 @@ private:
Private * const d;
};
Q_DECLARE_METATYPE( KoColor )
Q_DECLARE_METATYPE(KoColor)
#endif
......@@ -25,24 +25,25 @@
/**
* Converter from the alpha color space to any color space
*/
class KoColorConversionFromAlphaTransformation : public KoColorConversionTransformation {
public:
KoColorConversionFromAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent = IntentPerceptual);
virtual void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const;
class KoColorConversionFromAlphaTransformation : public KoColorConversionTransformation
{
public:
KoColorConversionFromAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent = IntentPerceptual);
virtual void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const;
};
//------ KoColorConversionFromAlphaTransformation ------//
KoColorConversionFromAlphaTransformation::KoColorConversionFromAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent ) : KoColorConversionTransformation(srcCs, dstCs, renderingIntent)
KoColorConversionFromAlphaTransformation::KoColorConversionFromAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent) : KoColorConversionTransformation(srcCs, dstCs, renderingIntent)
{
}
void KoColorConversionFromAlphaTransformation::transform(const quint8 *src, quint8 *dst, qint32 nPixels) const
{
qint32 size = dstColorSpace()->pixelSize();
while ( nPixels > 0 ) {
while (nPixels > 0) {
dstColorSpace()->setAlpha(dst, *src, 1);
......@@ -55,11 +56,11 @@ void KoColorConversionFromAlphaTransformation::transform(const quint8 *src, quin
//------ KoColorConversionFromAlphaTransformationFactory ------//
KoColorConversionFromAlphaTransformationFactory::KoColorConversionFromAlphaTransformationFactory(const QString& _dstModelId, const QString& _dstDepthId, const QString& _dstProfileName) : KoColorConversionTransformationFactory( AlphaColorModelID.id(), Integer8BitsColorDepthID.id(), "", _dstModelId, _dstDepthId, _dstProfileName )
KoColorConversionFromAlphaTransformationFactory::KoColorConversionFromAlphaTransformationFactory(const QString& _dstModelId, const QString& _dstDepthId, const QString& _dstProfileName) : KoColorConversionTransformationFactory(AlphaColorModelID.id(), Integer8BitsColorDepthID.id(), "", _dstModelId, _dstDepthId, _dstProfileName)
{
}
KoColorConversionTransformation* KoColorConversionFromAlphaTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent ) const
KoColorConversionTransformation* KoColorConversionFromAlphaTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent) const
{
Q_ASSERT(canBeSource(srcColorSpace));
Q_ASSERT(canBeDestination(dstColorSpace));
......@@ -81,23 +82,24 @@ bool KoColorConversionFromAlphaTransformationFactory::conserveDynamicRange() con
/**
* Converter to the alpha color space to any color space
*/
class KoColorConversionToAlphaTransformation : public KoColorConversionTransformation {
public:
KoColorConversionToAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent = IntentPerceptual);
virtual void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const;
class KoColorConversionToAlphaTransformation : public KoColorConversionTransformation
{
public:
KoColorConversionToAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent = IntentPerceptual);
virtual void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const;
};
KoColorConversionToAlphaTransformation::KoColorConversionToAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent ) : KoColorConversionTransformation(srcCs, dstCs, renderingIntent)
KoColorConversionToAlphaTransformation::KoColorConversionToAlphaTransformation(const KoColorSpace* srcCs, const KoColorSpace* dstCs, Intent renderingIntent) : KoColorConversionTransformation(srcCs, dstCs, renderingIntent)
{
}
void KoColorConversionToAlphaTransformation::transform(const quint8 *src, quint8 *dst, qint32 nPixels) const
{
qint32 size = srcColorSpace()->pixelSize();
while ( nPixels > 0 ) {
while (nPixels > 0) {
*dst = srcColorSpace()->alpha(src);
......@@ -112,11 +114,11 @@ void KoColorConversionToAlphaTransformation::transform(const quint8 *src, quint8
//------ KoColorConversionToAlphaTransformationFactory ------//
KoColorConversionToAlphaTransformationFactory::KoColorConversionToAlphaTransformationFactory(const QString& _srcModelId, const QString& _srcDepthId, const QString& _srcProfileName)
: KoColorConversionTransformationFactory( _srcModelId, _srcDepthId, _srcProfileName, AlphaColorModelID.id(), Integer8BitsColorDepthID.id(), "")
: KoColorConversionTransformationFactory(_srcModelId, _srcDepthId, _srcProfileName, AlphaColorModelID.id(), Integer8BitsColorDepthID.id(), "")
{
}
KoColorConversionTransformation* KoColorConversionToAlphaTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent ) const
KoColorConversionTransformation* KoColorConversionToAlphaTransformationFactory::createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent) const
{
Q_ASSERT(canBeSource(srcColorSpace));
Q_ASSERT(canBeDestination(dstColorSpace));
......
......@@ -28,12 +28,13 @@
* This class is for use by the KoColorConversionSystemn, no reason
* to use it directly.
*/
class KoColorConversionFromAlphaTransformationFactory : public KoColorConversionTransformationFactory {
public:
KoColorConversionFromAlphaTransformationFactory(const QString& _dstModelId, const QString& _dstDepthId, const QString& _dstProfileName);
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const;
virtual bool conserveColorInformation() const;
virtual bool conserveDynamicRange() const;
class KoColorConversionFromAlphaTransformationFactory : public KoColorConversionTransformationFactory
{
public:
KoColorConversionFromAlphaTransformationFactory(const QString& _dstModelId, const QString& _dstDepthId, const QString& _dstProfileName);
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const;
virtual bool conserveColorInformation() const;
virtual bool conserveDynamicRange() const;
};
/**
......@@ -41,12 +42,13 @@ class KoColorConversionFromAlphaTransformationFactory : public KoColorConversion
* This class is for use by the KoColorConversionSystemn, no reason
* to use it directly.
*/
class KoColorConversionToAlphaTransformationFactory : public KoColorConversionTransformationFactory {
public:
KoColorConversionToAlphaTransformationFactory(const QString& _dstModelId, const QString& _dstDepthId, const QString& _srcProfileName);
virtual KoColorConversionTransformation* createColorTransformation(const KoColorSpace* srcColorSpace, const KoColorSpace* dstColorSpace, KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::IntentPerceptual) const;
virtual bool conserveColorInformation() const;
virtual bool conserveDynamicRange() const;