Commit 8371c417 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Enable Gamut color and proofing intent.

The image now stored proofing intent, and the monitor intent is the general
rendering intent.

This also allows us to set the gamut warning color, however, for updating
you currently need to switch profiles as well. I'll make a seperate
generateSoftProofingTransform function, to cache the transform better, so it's
easier to update.

Ref 2337
parent 9d9ce380
......@@ -47,13 +47,17 @@ public:
const KoColorSpace* dstColorSpace,
const KoColorSpace* proofingSpace,
KoColorProofingConversionTransformation::Intent renderingIntent,
KoColorProofingConversionTransformation::ConversionFlags conversionFlags) const
KoColorProofingConversionTransformation::Intent proofingIntent,
KoColorProofingConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
{
Q_UNUSED(srcColorSpace);
Q_UNUSED(dstColorSpace);
Q_UNUSED(proofingSpace);
Q_UNUSED(renderingIntent);
Q_UNUSED(proofingIntent);
Q_UNUSED(conversionFlags);
Q_UNUSED(gamutWarning);
qFatal("createColorProofinTransform undefined.");
return 0;
}
......
......@@ -26,10 +26,14 @@ KoColorProofingConversionTransformation::KoColorProofingConversionTransformation
const KoColorSpace* dstCs,
const KoColorSpace* proofingSpace,
Intent renderingIntent,
ConversionFlags conversionFlags)
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning)
: KoColorConversionTransformation(srcCs, dstCs, renderingIntent, conversionFlags)
{
Q_ASSERT(proofingSpace);
m_proofingIntent = proofingIntent;
m_gamutWarning = gamutWarning;
m_proofingSpace = proofingSpace;
}
......
......@@ -38,7 +38,9 @@ public:
const KoColorSpace *dstCs,
const KoColorSpace *proofingSpace,
Intent renderingIntent,
ConversionFlags conversionFlags);
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning);
virtual ~KoColorProofingConversionTransformation();
public:
......@@ -51,6 +53,8 @@ public:
private:
Intent m_proofingIntent;
quint8 *m_gamutWarning;
const KoColorSpace *m_proofingSpace;
};
......
......@@ -71,6 +71,7 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp
d->proofingSpace = "";
d->softProofing = false;
d->gamutCheck = false;
d->gamutWarning = 0;
d->proofingTransform = 0;
d->deletability = NotOwnedByRegistry;
}
......@@ -441,13 +442,15 @@ bool KoColorSpace::convertPixelsTo(const quint8 * src,
}
return true;
}
bool KoColorSpace::proofPixelsTo(const quint8 * src,
quint8 * dst,
const KoColorSpace * dstColorSpace,
const KoColorSpace * proofingSpace,
bool KoColorSpace::proofPixelsTo(const quint8 *src,
quint8 *dst,
const KoColorSpace *dstColorSpace,
const KoColorSpace *proofingSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags) const
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
{
/*if (*this == *dstColorSpace) {
if (src != dst) {
......@@ -464,8 +467,9 @@ bool KoColorSpace::proofPixelsTo(const quint8 * src,
if (!d->iccEngine) return false;
if (d->proofingSpace!=proofingSpace->profile()->name()+dstColorSpace->profile()->name() || d->softProofing!=conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing) || d->gamutCheck!=conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck)) {
d->proofingTransform = d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, conversionFlags);
d->proofingTransform = d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning);
d->proofingSpace = proofingSpace->profile()->name()+dstColorSpace->profile()->name();
d->gamutWarning = gamutWarning;
d->softProofing = conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing);
d->gamutCheck = conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck);
}
......
......@@ -376,11 +376,13 @@ public:
* @brief proofPixelsTo
* @param src
* @param dst
* @param dstColorSpace
* @param proofingSpace
* @param numPixels
* @param renderingIntent
* @param conversionFlags
* @param dstColorSpace the colorspace to which we go to.
* @param proofingSpace the proofing space.
* @param numPixels the amount of pixels.
* @param renderingIntent the rendering intent used for rendering.
* @param proofingIntent the intent used for proofing.
* @param conversionFlags the conversion flags.
* @param gamutWarning the data() of a KoColor.
* @return
*/
virtual bool proofPixelsTo(const quint8 * src,
......@@ -388,7 +390,9 @@ public:
const KoColorSpace * proofingSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags) const;
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const;
//============================== Manipulation functions ==========================//
......
......@@ -331,7 +331,7 @@ KisOpenGLUpdateInfoSP KisOpenGLImageTextures::updateCacheImpl(const QRect& rect,
if (!proofingSpace){
qDebug()<<"Proofing space is incorrect";
}
tileInfo->proofTo(dstCS, proofingSpace, m_proofingConfig->intent, m_proofingConfig->conversionFlags);
tileInfo->proofTo(dstCS, proofingSpace, m_renderingIntent, m_proofingConfig->intent, m_proofingConfig->conversionFlags, m_proofingConfig->warningColor);
} else {
tileInfo->convertTo(dstCS, m_renderingIntent, m_conversionFlags);
}
......
......@@ -211,7 +211,9 @@ public:
void proofTo(const KoColorSpace* dstCS, const KoColorSpace* proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags)
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
KoColor gamutWarning)
{
if (dstCS == m_patchColorSpace && conversionFlags == KoColorConversionTransformation::Empty) return;
......@@ -220,7 +222,7 @@ public:
const quint32 conversionCacheLength = numPixels * dstCS->pixelSize();
m_conversionCache.ensureNotSmaller(conversionCacheLength);
m_patchColorSpace->proofPixelsTo(m_patchPixels.data(), m_conversionCache.data(), dstCS, proofingSpace, numPixels, renderingIntent, conversionFlags);
m_patchColorSpace->proofPixelsTo(m_patchPixels.data(), m_conversionCache.data(), dstCS, proofingSpace, numPixels, renderingIntent,proofingIntent, conversionFlags, gamutWarning.data());
m_patchColorSpace = dstCS;
m_conversionCache.swap(m_patchPixels);
......
......@@ -101,9 +101,11 @@ public:
const KoColorSpace *dstCs, quint32 dstColorSpaceType, LcmsColorProfileContainer *dstProfile,
const KoColorSpace *proofingSpace,
Intent renderingIntent,
ConversionFlags conversionFlags
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning
)
: KoColorProofingConversionTransformation(srcCs, dstCs, proofingSpace, renderingIntent, conversionFlags)
: KoColorProofingConversionTransformation(srcCs, dstCs, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning)
, m_transform(0)
{
Q_ASSERT(srcCs);
......@@ -120,15 +122,16 @@ public:
}
}
quint16 alarm[cmsMAXCHANNELS];//cyan!
alarm[0] = 0;
alarm[1] = 65535;
alarm[2] = 65535;
quint16 alarm[cmsMAXCHANNELS];//this seems to be bgr???
alarm[0] = (cmsUInt16Number)gamutWarning[2]*256;
alarm[1] = (cmsUInt16Number)gamutWarning[1]*256;
alarm[2] = (cmsUInt16Number)gamutWarning[0]*256;
cmsSetAlarmCodes(alarm);
qDebug()<<"Test gamut check";
qDebug()<<conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck);
qDebug()<<conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing);
qDebug()<<alarm[0]<<", "<< alarm[1]<<", "<< alarm[2];
m_transform = cmsCreateProofingTransform(srcProfile->lcmsProfile(),
srcColorSpaceType,
......@@ -136,7 +139,7 @@ public:
dstColorSpaceType,
dynamic_cast<const IccColorProfile *>(proofingSpace->profile())->asLcms()->lcmsProfile(),
renderingIntent,
renderingIntent,
proofingIntent,
conversionFlags);
Q_ASSERT(m_transform);
......@@ -242,8 +245,9 @@ KoColorProofingConversionTransformation *IccColorSpaceEngine::createColorProofin
const KoColorSpace *dstColorSpace,
const KoColorSpace *proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags
) const
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
{
Q_ASSERT(srcColorSpace);
Q_ASSERT(dstColorSpace);
......@@ -251,7 +255,7 @@ KoColorProofingConversionTransformation *IccColorSpaceEngine::createColorProofin
return new KoLcmsColorProofingConversionTransformation(
srcColorSpace, computeColorSpaceType(srcColorSpace),
dynamic_cast<const IccColorProfile *>(srcColorSpace->profile())->asLcms(), dstColorSpace, computeColorSpaceType(dstColorSpace),
dynamic_cast<const IccColorProfile *>(dstColorSpace->profile())->asLcms(), proofingSpace, renderingIntent, conversionFlags
dynamic_cast<const IccColorProfile *>(dstColorSpace->profile())->asLcms(), proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning
);
}
......
......@@ -36,8 +36,8 @@ public:
virtual KoColorProofingConversionTransformation *createColorProofingTransformation(const KoColorSpace *srcColorSpace,
const KoColorSpace *dstColorSpace,
const KoColorSpace *proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags) const;
KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning) const;
quint32 computeColorSpaceType(const KoColorSpace *cs) const;
private:
struct Private;
......
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