Commit 7bb99a0a authored by Casper Boemann's avatar Casper Boemann

Added a L*a*b colorspace.

Still not ready for primetime yet


svn path=/trunk/koffice/; revision=487971
parent 70cba21f
......@@ -7,6 +7,7 @@ noinst_LTLIBRARIES = libkritacolorspaces.la
libkritacolorspaces_la_SOURCES = \
kis_alpha_colorspace.cc \
kis_lab_colorspace.cc \
kis_xyz_colorspace.cc
noinst_HEADERS = \
......
This diff is collapsed.
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_STRATEGY_COLORSPACE_LAB_H_
#define KIS_STRATEGY_COLORSPACE_LAB_H_
#include <qcolor.h>
#include <klocale.h>
#include <koffice_export.h>
#include "kis_global.h"
#include "kis_integer_maths.h"
#include "kis_abstract_colorspace.h"
class KRITATOOL_EXPORT KisLabColorSpace : public KisAbstractColorSpace {
public:
KisLabColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisLabColorSpace();
public:
virtual QValueVector<KisChannelInfo *> channels() const;
virtual Q_UINT32 nChannels() const;
virtual Q_UINT32 nColorChannels() const;
virtual Q_UINT32 pixelSize() const;
virtual QString channelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual QString normalisedChannelValueText(const Q_UINT8 *pixel, Q_UINT32 channelIndex) const;
virtual Q_UINT8 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 KisCompositeOpList userVisiblecompositeOps() const;
virtual Q_UINT8 getAlpha(const Q_UINT8 * pixel);
virtual void setAlpha(Q_UINT8 * pixels, Q_UINT8 alpha, Q_INT32 nPixels);
virtual void multiplyAlpha(Q_UINT8 * pixels, Q_UINT8 alpha, Q_INT32 nPixels);
virtual void applyAlphaU8Mask(Q_UINT8 * pixels, Q_UINT8 * alpha, Q_INT32 nPixels);
virtual void applyInverseAlphaU8Mask(Q_UINT8 * pixels, Q_UINT8 * alpha, Q_INT32 nPixels);
virtual Q_UINT8 scaleToU8(const Q_UINT8 * srcPixel, Q_INT32 channelPos);
virtual Q_UINT16 scaleToU16(const Q_UINT8 * srcPixel, Q_INT32 channelPos);
protected:
virtual void bitBlt(Q_UINT8 *dst,
Q_INT32 dstRowStride,
const Q_UINT8 *src,
Q_INT32 srcRowStride,
const Q_UINT8 *srcAlphaMask,
Q_INT32 maskRowStride,
Q_UINT8 opacity,
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op);
void compositeCopy(Q_UINT8 *dstRowStart, Q_INT32 dstRowStride, const Q_UINT8 *srcRowStart, Q_INT32 srcRowStride, const Q_UINT8 *maskRowStart, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 numColumns, Q_UINT8 opacity);
void compositeOver(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
/*
void compositeMultiply(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeDivide(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeScreen(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeOverlay(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeDodge(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeBurn(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeDarken(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeLighten(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeHue(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeSaturation(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeValue(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
void compositeColor(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
*/
void compositeErase(Q_UINT8 *dst, Q_INT32 dstRowStride, const Q_UINT8 *src, Q_INT32 srcRowStride, const Q_UINT8 *mask, Q_INT32 maskRowStride, Q_INT32 rows, Q_INT32 columns, Q_UINT16 opacity);
private:
struct Pixel {
Q_UINT16 lightness;
Q_INT16 a;
Q_INT16 b;
Q_UINT16 alpha;
};
static const Q_UINT16 U16_OPACITY_OPAQUE = UINT16_MAX;
static const Q_UINT16 U16_OPACITY_TRANSPARENT = UINT16_MIN;
friend class KisLabColorSpaceTester;
};
class KisLabColorSpaceFactory : public KisColorSpaceFactory
{
public:
/**
* Krita definition for use in .kra files and internally: unchanging name +
* i18n'able description.
*/
virtual KisID id() const { return KisID("LABA", i18n("L*a*b (16-bit integer/channel)")); };
/**
* lcms colorspace type definition.
*/
virtual Q_UINT32 colorSpaceType() { return (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1)); };
virtual icColorSpaceSignature colorSpaceSignature() { return icSigLabData; };
virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisLabColorSpace(parent, p); };
virtual QString defaultProfile() { return ""; };
};
#endif // KIS_STRATEGY_COLORSPACE_LAB_H_
......@@ -30,13 +30,13 @@
#include "kis_colorspace_factory_registry.h"
#include "kis_xyz_colorspace.h"
#include "kis_alpha_colorspace.h"
#include "kis_lab_colorspace.h"
KisColorSpaceFactoryRegistry::KisColorSpaceFactoryRegistry(QStringList profileFilenames)
{
// Create the built-in colorspaces
m_xyzCs = new KisXyzColorSpace(this, 0);
m_alphaCs = new KisAlphaColorSpace(this, 0);
// Load the profiles
......@@ -53,6 +53,9 @@ KisColorSpaceFactoryRegistry::KisColorSpaceFactoryRegistry(QStringList profileFi
}
}
KisProfile *labProfile = new KisProfile(cmsCreateLabProfile(NULL));
addProfile(labProfile);
// Load all colorspace modules
KTrader::OfferList offers = KTrader::self() -> query(QString::fromLatin1("Krita/ColorSpace"),
QString::fromLatin1("(Type == 'Service') and "
......@@ -73,7 +76,7 @@ KisColorSpaceFactoryRegistry::KisColorSpaceFactoryRegistry(QStringList profileFi
if ( plugin )
kdDebug(DBG_AREA_PLUGINS) << "found colorspace " << service -> property("Name").toString() << "\n";
}
add(new KisLabColorSpaceFactory());
}
KisColorSpaceFactoryRegistry::KisColorSpaceFactoryRegistry()
......@@ -176,12 +179,6 @@ KisColorSpace * KisColorSpaceFactoryRegistry::getColorSpace(const KisID & csID,
}
}
KisColorSpace * KisColorSpaceFactoryRegistry::getXYZ16()
{
return m_xyzCs;
}
KisColorSpace * KisColorSpaceFactoryRegistry::getAlpha8()
{
return m_alphaCs;
......
......@@ -28,10 +28,9 @@ class KisPaintDeviceAction;
/**
* This class contains:
* - a registry of singleton color strategies.
* - a registry of colorspace instantiated with specific profiles.
* - a registry of singleton colorspace factories.
* - a registry of icc profiles
* - a registry of default pixel operations
* - a registry of actions that can be performed when a layer with a colorstrategy is made
*/
class KisColorSpaceFactoryRegistry : public QObject, public KisGenericRegistry<KisColorSpaceFactory *> {
......@@ -80,18 +79,13 @@ public:
*/
KisColorSpace * getColorSpace(const KisID & csID, const KisProfile * profile);
/**
* Convenience method to get the often used xyz16 colorspace
*/
KisColorSpace * getXYZ16();
/**
* Convenience method to get the often used alpha colorspace
*/
KisColorSpace * getAlpha8();
/**
* Convenience method an RGB colorspace with the default lcms profile
* Convenience method to get an RGB colorspace with the default lcms profile
*/
KisColorSpace * getRGB8();
......@@ -119,7 +113,6 @@ private:
QMap<QString, KisColorSpace * > m_csMap;
typedef QValueVector<KisPaintDeviceAction *> PaintActionVector;
QMap<KisID, PaintActionVector> m_paintDevActionMap;
KisColorSpace *m_xyzCs;
KisColorSpace *m_alphaCs;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment