Commit b33ca33d authored by Casper Boemann's avatar Casper Boemann
Browse files

Port Boudewijn's lab to/from functions from 1.6 branch

svn path=/trunk/koffice/; revision=547458
parent 4917be4f
......@@ -53,6 +53,21 @@ KisLabColorSpace::~KisLabColorSpace()
{
}
quint8 * KisLabColorSpace::toLabA16(const quint8 * data, const quint32 nPixels) const
{
quint8 * pixels = new quint8[nPixels * pixelSize()];
memcpy( pixels, data, nPixels * pixelSize() );
return pixels;
}
quint8 * KisLabColorSpace::fromLabA16(const quint8 * labData, const quint32 nPixels) const
{
quint8 * pixels = new quint8[nPixels * pixelSize()];
memcpy( pixels, labData, nPixels * pixelSize() );
return pixels;
}
quint8 KisLabColorSpace::difference(const quint8 *src1, const quint8 *src2)
{
cmsCIELab labF1, labF2;
......
......@@ -34,6 +34,20 @@ public:
public:
/**
* Return a COPY of the provided data. This method is provided to provide consistency,
* but you really don't want to be calling it.
*/
virtual quint8 * toLabA16(const quint8 * data, const quint32 nPixels) const;
/**
* Return a COPY of the provided data. This method is provided for consistency,
* but you really don't want to call it.
*/
virtual quint8 * fromLabA16(const quint8 * labData, const quint32 nPixels) const;
virtual bool willDegrade(ColorSpaceIndependence independence)
{
if (independence == TO_RGBA8)
......
......@@ -33,7 +33,7 @@
class KisColorAdjustmentImpl : public KisColorAdjustment
{
public:
KisColorAdjustmentImpl() : KisColorAdjustment()
{
csProfile = 0;
......@@ -42,7 +42,7 @@ class KisColorAdjustmentImpl : public KisColorAdjustment
profiles[1] = 0;
profiles[2] = 0;
};
~KisColorAdjustmentImpl() {
if (transform)
......@@ -188,6 +188,30 @@ void KisAbstractColorSpace::getSingleChannelPixel(quint8 *dstPixel, const quint8
}
}
quint8 * KisAbstractColorSpace::toLabA16(const quint8 * data, const quint32 nPixels) const
{
if ( m_defaultToLab == 0 ) return 0;
// 4 channels: labA, 2 bytes per lab channel
quint8 * pixels = new quint8[nPixels * 2 * 4];
cmsDoTransform( m_defaultToLab, const_cast<quint8 *>( data ), pixels, nPixels );
return pixels;
}
quint8 * KisAbstractColorSpace::fromLabA16(const quint8 * labData, const quint32 nPixels) const
{
if ( m_defaultFromLab == 0 ) return 0;
quint8 * pixels = new quint8[nPixels * pixelSize()];
cmsDoTransform( m_defaultFromLab, const_cast<quint8 *>( labData ), pixels, nPixels );
return pixels;
}
bool KisAbstractColorSpace::convertPixelsTo(const quint8 * src,
quint8 * dst,
KisColorSpace * dstColorSpace,
......@@ -209,7 +233,7 @@ bool KisAbstractColorSpace::convertPixelsTo(const quint8 * src,
qint32 dstPixelSize = dstColorSpace->pixelSize();
if (m_lastUsedTransform != 0 && m_lastUsedDstColorSpace != 0) {
if (dstColorSpace->colorSpaceType() == m_lastUsedDstColorSpace->colorSpaceType() &&
if (dstColorSpace->colorSpaceType() == m_lastUsedDstColorSpace->colorSpaceType() &&
dstColorSpace->getProfile() == m_lastUsedDstColorSpace->getProfile()) {
tf = m_lastUsedTransform;
}
......@@ -332,7 +356,7 @@ KisColorAdjustment *KisAbstractColorSpace::createDesaturateAdjustment()
adj->profiles[0] = m_profile->profile();
adj->profiles[2] = m_profile->profile();
adj->csProfile = m_profile->profile();
LPLUT Lut;
BCHSWADJUSTS bchsw;
......
......@@ -135,6 +135,9 @@ public:
qint32 renderingIntent = INTENT_PERCEPTUAL,
float exposure = 0.0f);
virtual quint8 * toLabA16(const quint8 * data, const quint32 nPixels) const;
virtual quint8 * fromLabA16(const quint8 * labData, const quint32 nPixels) const;
virtual bool convertPixelsTo(const quint8 * src,
quint8 * dst, KisColorSpace * dstColorSpace,
quint32 numPixels,
......
......@@ -248,6 +248,30 @@ public:
KisProfile * dstProfile, qint32 renderingIntent = INTENT_PERCEPTUAL,
float exposure = 0.0f) = 0;
/**
* Convert the specified data to Lab. This functions allocates the ncessary memory:
* it is your responsibility to delete[] it. If this colorspace is not able to
* convert to lab, the function returns 0 (a recipe for a crash, so check it.)
* Note that the default conversion profile is used; converting back using the next
* function should be safe.
*
* @param data the source data
* @param nPixels the number of source pixels
* @return a pointer to a new array containing the lab pixels
*/
virtual quint8 * toLabA16(const quint8 * /*data*/, const quint32 /*nPixels*/) const { return 0; }
/**
* Convert a byte array of nPixels pixels * labData to the current colorspace.
* Allocates the necessary memory and expects YOU to delete[] it. If this
* colorspaxe cannot convert from lab, the function returns 0 (a recipe for a
* crash, so check it.)
*
* @param labData the pixels in 16 bit lab format
* @param nPxiels the number of pixels in the array
* @return a pointer to a new array containing the pixels in this colorspace
*/
virtual Q_UINT8 * fromLabA16(const quint8 * /*labData*/, const quint32 /*nPixels*/) const { return 0; }
/**
......
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