Commit 60e001db authored by Boudewijn Rempt's avatar Boudewijn Rempt

Krita is now even more a KOffice app: four space, no tabs for indenting. Reset your editors!

svn path=/trunk/koffice/; revision=445149
parent a627cbd5
......@@ -32,72 +32,72 @@
*/
class KisAlphaColorSpace : public KisAbstractColorSpace {
public:
KisAlphaColorSpace();
virtual ~KisAlphaColorSpace();
KisAlphaColorSpace();
virtual ~KisAlphaColorSpace();
public:
virtual void nativeColor(const QColor& c, Q_UINT8 *dst, KisProfileSP profile = 0);
virtual void nativeColor(const QColor& c, QUANTUM opacity, Q_UINT8 *dst, KisProfileSP profile = 0);
virtual void nativeColor(const QColor& c, Q_UINT8 *dst, KisProfileSP profile = 0);
virtual void nativeColor(const QColor& c, QUANTUM opacity, Q_UINT8 *dst, KisProfileSP profile = 0);
virtual void getAlpha(const Q_UINT8 *pixel, Q_UINT8 *alpha);
virtual void getAlpha(const Q_UINT8 *pixel, Q_UINT8 *alpha);
virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfileSP profile = 0);
virtual void toQColor(const Q_UINT8 *src, QColor *c, QUANTUM *opacity, KisProfileSP profile = 0);
virtual void toQColor(const Q_UINT8 *src, QColor *c, KisProfileSP profile = 0);
virtual void toQColor(const Q_UINT8 *src, QColor *c, QUANTUM *opacity, KisProfileSP profile = 0);
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src, KisProfileSP profile = 0) { return KisPixelRO (src, src, this, profile); }
virtual KisPixel toKisPixel(Q_UINT8 *src, KisProfileSP profile = 0) { return KisPixel (src, src, this, profile); }
virtual Q_INT8 difference(const Q_UINT8 *src1, const Q_UINT8 *src2);
virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const;
virtual KisPixelRO toKisPixelRO(const Q_UINT8 *src, KisProfileSP profile = 0) { return KisPixelRO (src, src, this, profile); }
virtual KisPixel toKisPixel(Q_UINT8 *src, KisProfileSP profile = 0) { return KisPixel (src, src, this, profile); }
virtual Q_INT8 difference(const Q_UINT8 *src1, const Q_UINT8 *src2);
virtual void mixColors(const Q_UINT8 **colors, const Q_UINT8 *weights, Q_UINT32 nColors, Q_UINT8 *dst) const;
virtual vKisChannelInfoSP channels() const;
virtual bool hasAlpha() const;
virtual Q_INT32 nChannels() const { return 1; };
virtual Q_INT32 nColorChannels() const { return 0; };
virtual Q_INT32 pixelSize() const { return 1; };
virtual vKisChannelInfoSP channels() const;
virtual bool hasAlpha() const;
virtual Q_INT32 nChannels() const { return 1; };
virtual Q_INT32 nColorChannels() const { return 0; };
virtual Q_INT32 pixelSize() const { return 1; };
virtual QString channelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual QString normalisedChannelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual QString channelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual QString normalisedChannelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual QImage convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height,
KisProfileSP srcProfile, KisProfileSP dstProfile,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL,
float exposure = 0.0f);
virtual QImage convertToQImage(const Q_UINT8 *data, Q_INT32 width, Q_INT32 height,
KisProfileSP srcProfile, KisProfileSP dstProfile,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL,
float exposure = 0.0f);
virtual void adjustBrightnessContrast(const Q_UINT8 *src, Q_UINT8 *dst, Q_INT8 brightness, Q_INT8 contrast, Q_INT32 nPixels) const;
virtual void adjustBrightnessContrast(const Q_UINT8 *src, Q_UINT8 *dst, Q_INT8 brightness, Q_INT8 contrast, Q_INT32 nPixels) const;
virtual void convolveColors(Q_UINT8** colors, Q_INT32* kernelValues, enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const;
virtual void convolveColors(Q_UINT8** colors, Q_INT32* kernelValues, enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const;
protected:
/**
* Convert a byte array of srcLen pixels *src to the specified color space
* and put the converted bytes into the prepared byte array *dst.
*
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const Q_UINT8 *src, KisProfileSP srcProfile,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorStrategy, KisProfileSP dstProfile,
Q_UINT32 numPixels,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
/**
* Convert a byte array of srcLen pixels *src to the specified color space
* and put the converted bytes into the prepared byte array *dst.
*
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const Q_UINT8 *src, KisProfileSP srcProfile,
Q_UINT8 *dst, KisAbstractColorSpace * dstColorStrategy, KisProfileSP dstProfile,
Q_UINT32 numPixels,
Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
virtual void bitBlt(Q_UINT8 *dst,
Q_INT32 dststride,
const Q_UINT8 *src,
Q_INT32 srcRowStride,
const Q_UINT8 *srcAlphaMask,
Q_INT32 maskRowStride,
QUANTUM opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op);
virtual void bitBlt(Q_UINT8 *dst,
Q_INT32 dststride,
const Q_UINT8 *src,
Q_INT32 srcRowStride,
const Q_UINT8 *srcAlphaMask,
Q_INT32 maskRowStride,
QUANTUM opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op);
KisCompositeOpList userVisiblecompositeOps() const;
KisCompositeOpList userVisiblecompositeOps() const;
private:
vKisChannelInfoSP m_channels;
vKisChannelInfoSP m_channels;
};
#endif // KIS_COLORSPACE_ALPHA_H_
......@@ -26,8 +26,8 @@ KisColorSpaceRegistry *KisColorSpaceRegistry::m_singleton = 0;
KisColorSpaceRegistry::KisColorSpaceRegistry()
{
Q_ASSERT(KisColorSpaceRegistry::m_singleton == 0);
KisColorSpaceRegistry::m_singleton = this;
Q_ASSERT(KisColorSpaceRegistry::m_singleton == 0);
KisColorSpaceRegistry::m_singleton = this;
}
KisColorSpaceRegistry::~KisColorSpaceRegistry()
......@@ -36,22 +36,22 @@ KisColorSpaceRegistry::~KisColorSpaceRegistry()
KisColorSpaceRegistry* KisColorSpaceRegistry::instance()
{
if(KisColorSpaceRegistry::m_singleton == 0)
{
KisColorSpaceRegistry::m_singleton = new KisColorSpaceRegistry();
Q_CHECK_PTR(KisColorSpaceRegistry::m_singleton);
m_singleton->add(new KisXyzColorSpace());
}
return KisColorSpaceRegistry::m_singleton;
if(KisColorSpaceRegistry::m_singleton == 0)
{
KisColorSpaceRegistry::m_singleton = new KisColorSpaceRegistry();
Q_CHECK_PTR(KisColorSpaceRegistry::m_singleton);
m_singleton->add(new KisXyzColorSpace());
}
return KisColorSpaceRegistry::m_singleton;
}
KisProfileSP KisColorSpaceRegistry::getProfileByName(const QString & name) const
{
KisProfileSP profile = 0;
KisIDList keys = listKeys();
for ( KisIDList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
profile = get(*it) -> getProfileByName(name);
if (profile != 0) return profile;
}
return profile;
KisProfileSP profile = 0;
KisIDList keys = listKeys();
for ( KisIDList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
profile = get(*it) -> getProfileByName(name);
if (profile != 0) return profile;
}
return profile;
}
......@@ -29,27 +29,27 @@ class QStringList;
/**
* This class will contain:
* - a registry of singleton color strategies
* - a mapping of ImageMagick color model identifiers to color strategies
* - a registry of singleton color strategies
* - a mapping of ImageMagick color model identifiers to color strategies
* - a mapping of lcms color model identifiers to color strategies
* - a mapping of icm color model identifiers to color stratiegs
*/
class KRITACORE_EXPORT KisColorSpaceRegistry : public KisGenericRegistry<KisAbstractColorSpace *> {
public:
virtual ~KisColorSpaceRegistry();
virtual ~KisColorSpaceRegistry();
static KisColorSpaceRegistry* instance();
static KisColorSpaceRegistry* instance();
KisProfileSP getProfileByName(const QString & name) const;
KisProfileSP getProfileByName(const QString & name) const;
private:
KisColorSpaceRegistry();
KisColorSpaceRegistry(const KisColorSpaceRegistry&);
KisColorSpaceRegistry operator=(const KisColorSpaceRegistry&);
KisColorSpaceRegistry();
KisColorSpaceRegistry(const KisColorSpaceRegistry&);
KisColorSpaceRegistry operator=(const KisColorSpaceRegistry&);
private:
static KisColorSpaceRegistry *m_singleton;
static KisColorSpaceRegistry *m_singleton;
};
......
......@@ -29,199 +29,199 @@ KUNITTEST_MODULE_REGISTER_TESTER(KisColorConversionsTester);
void KisColorConversionsTester::allTests()
{
testRGBHSV();
testRGBHSL();
testRGBHSV();
testRGBHSL();
}
#define EPSILON 1e-6
void KisColorConversionsTester::testRGBHSV()
{
float r, g, b, h, s, v;
RGBToHSV(1, 0, 0, &h, &s, &v);
CHECK(h, 0.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(1, 1, 0, &h, &s, &v);
CHECK(h, 60.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 1, 0, &h, &s, &v);
CHECK(h, 120.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 1, 1, &h, &s, &v);
CHECK(h, 180.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 0, 1, &h, &s, &v);
CHECK(h, 240.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(1, 0, 1, &h, &s, &v);
CHECK(h, 300.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 0, 0, &h, &s, &v);
CHECK(h, -1.0f);
CHECK(s, 0.0f);
CHECK(v, 0.0f);
RGBToHSV(1, 1, 1, &h, &s, &v);
CHECK(h, -1.0f);
CHECK(s, 0.0f);
CHECK(v, 1.0f);
RGBToHSV(0.5, 0.25, 0.75, &h, &s, &v);
CHECK_TOLERANCE(h, 270.0f, EPSILON);
CHECK_TOLERANCE(s, 0.666667f, EPSILON);
CHECK_TOLERANCE(v, 0.75f, EPSILON);
HSVToRGB(0, 1, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 0.0f);
CHECK(b, 0.0f);
HSVToRGB(60, 1, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 1.0f);
CHECK(b, 0.0f);
HSVToRGB(120, 1, 1, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 1.0f);
CHECK(b, 0.0f);
HSVToRGB(180, 1, 1, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 1.0f);
CHECK(b, 1.0f);
HSVToRGB(240, 1, 1, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 0.0f);
CHECK(b, 1.0f);
HSVToRGB(300, 1, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 0.0f);
CHECK(b, 1.0f);
HSVToRGB(-1, 0, 0, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 0.0f);
CHECK(b, 0.0f);
HSVToRGB(-1, 0, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 1.0f);
CHECK(b, 1.0f);
HSVToRGB(270, 0.666667, 0.75, &r, &g, &b);
CHECK_TOLERANCE(r, 0.5f, EPSILON);
CHECK_TOLERANCE(g, 0.25f, EPSILON);
CHECK_TOLERANCE(b, 0.75f, EPSILON);
float r, g, b, h, s, v;
RGBToHSV(1, 0, 0, &h, &s, &v);
CHECK(h, 0.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(1, 1, 0, &h, &s, &v);
CHECK(h, 60.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 1, 0, &h, &s, &v);
CHECK(h, 120.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 1, 1, &h, &s, &v);
CHECK(h, 180.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 0, 1, &h, &s, &v);
CHECK(h, 240.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(1, 0, 1, &h, &s, &v);
CHECK(h, 300.0f);
CHECK(s, 1.0f);
CHECK(v, 1.0f);
RGBToHSV(0, 0, 0, &h, &s, &v);
CHECK(h, -1.0f);
CHECK(s, 0.0f);
CHECK(v, 0.0f);
RGBToHSV(1, 1, 1, &h, &s, &v);
CHECK(h, -1.0f);
CHECK(s, 0.0f);
CHECK(v, 1.0f);
RGBToHSV(0.5, 0.25, 0.75, &h, &s, &v);
CHECK_TOLERANCE(h, 270.0f, EPSILON);
CHECK_TOLERANCE(s, 0.666667f, EPSILON);
CHECK_TOLERANCE(v, 0.75f, EPSILON);
HSVToRGB(0, 1, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 0.0f);
CHECK(b, 0.0f);
HSVToRGB(60, 1, 1, &r, &g, &b);
CHECK(r, 1.0f);
CHECK(g, 1.0f);
CHECK(b, 0.0f);
HSVToRGB(120, 1, 1, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 1.0f);
CHECK(b, 0.0f);
HSVToRGB(180, 1, 1, &r, &g, &b);
CHECK(r, 0.0f);
CHECK(g, 1.0f);
CHECK(b, 1.0f);
HSVToRGB