Commit 652405d3 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Add adaptation state slider.

This allows you to set whether or not to adapt the white point, that is,
to set the white point to the screen white(full slider) or to convert all whiteson screen to the white point of the profile when using absolute colorimetric
as intent.

This is useful to simulate paper-colour.

Ref T2337
parent aea525ca
......@@ -18,13 +18,15 @@ struct KisProofingConfiguration {
warningColor(KoColor()),
proofingProfile("Chemical proof"),
proofingModel("CMYKA"),
proofingDepth("U8"){}
proofingDepth("U8"),
adaptationState(1.0){}
KoColorConversionTransformation::Intent intent;
KoColorConversionTransformation::ConversionFlags conversionFlags;
KoColor warningColor;
QString proofingProfile;
QString proofingModel;
QString proofingDepth;
double adaptationState;
};
......
......@@ -403,7 +403,7 @@ KisProofingConfiguration *KisImageConfig::defaultProofingconfiguration()
proofingConfig->proofingProfile = m_config.readEntry("defaultProofingProfileName", "Chemical proof");
proofingConfig->proofingModel = m_config.readEntry("defaultProofingProfileModel", "CMYKA");
proofingConfig->proofingDepth = m_config.readEntry("defaultProofingProfileDepth", "U8");
proofingConfig->intent = (KoColorConversionTransformation::Intent)m_config.readEntry("defaultProofingProfileIntent", 4);
proofingConfig->intent = (KoColorConversionTransformation::Intent)m_config.readEntry("defaultProofingProfileIntent", 3);
if (m_config.readEntry("defaultProofingBlackpointCompensation", true)) {
proofingConfig->conversionFlags |= KoColorConversionTransformation::ConversionFlag::BlackpointCompensation;
} else {
......@@ -414,10 +414,11 @@ KisProofingConfiguration *KisImageConfig::defaultProofingconfiguration()
KoColor col;
col.fromQColor(def);
proofingConfig->warningColor = col;
proofingConfig->adaptationState = (double)m_config.readEntry("defaultProofingAdaptationState", 1.0);
return proofingConfig;
}
void KisImageConfig::setDefaultProofingConfig(const KoColorSpace *proofingSpace, int proofingIntent, bool blackPointCompensation, KoColor warningColor)
void KisImageConfig::setDefaultProofingConfig(const KoColorSpace *proofingSpace, int proofingIntent, bool blackPointCompensation, KoColor warningColor, double adaptationState)
{
m_config.writeEntry("defaultProofingProfileName", proofingSpace->profile()->name());
m_config.writeEntry("defaultProofingProfileModel", proofingSpace->colorModelId().id());
......@@ -427,4 +428,5 @@ void KisImageConfig::setDefaultProofingConfig(const KoColorSpace *proofingSpace,
QColor c;
warningColor.toQColor(&c);
m_config.writeEntry("defaultProofingGamutwarning", c);
m_config.writeEntry("defaultProofingAdaptationState",adaptationState);
}
......@@ -103,7 +103,7 @@ public:
void setShowAdditionalOnionSkinsSettings(bool value);
KisProofingConfiguration *defaultProofingconfiguration();
void setDefaultProofingConfig(const KoColorSpace *proofingSpace, int proofingIntent, bool blackPointCompensation, KoColor warningColor);
void setDefaultProofingConfig(const KoColorSpace *proofingSpace, int proofingIntent, bool blackPointCompensation, KoColor warningColor, double adaptationState);
private:
......
......@@ -49,7 +49,8 @@ public:
KoColorProofingConversionTransformation::Intent renderingIntent,
KoColorProofingConversionTransformation::Intent proofingIntent,
KoColorProofingConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
quint8 *gamutWarning,
double adaptationState) const
{
Q_UNUSED(srcColorSpace);
Q_UNUSED(dstColorSpace);
......@@ -58,6 +59,7 @@ public:
Q_UNUSED(proofingIntent);
Q_UNUSED(conversionFlags);
Q_UNUSED(gamutWarning);
Q_UNUSED(adaptationState);
qFatal("createColorProofinTransform undefined.");
return 0;
}
......
......@@ -28,12 +28,14 @@ KoColorProofingConversionTransformation::KoColorProofingConversionTransformation
Intent renderingIntent,
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning)
quint8 *gamutWarning,
double adaptationState)
: KoColorConversionTransformation(srcCs, dstCs, renderingIntent, conversionFlags)
{
Q_ASSERT(proofingSpace);
m_proofingIntent = proofingIntent;
m_gamutWarning = gamutWarning;
m_adaptationState = adaptationState;
m_proofingSpace = proofingSpace;
}
......
......@@ -40,7 +40,8 @@ public:
Intent renderingIntent,
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning);
quint8 *gamutWarning,
double adaptationState);
virtual ~KoColorProofingConversionTransformation();
public:
......@@ -55,6 +56,7 @@ private:
Intent m_proofingIntent;
quint8 *m_gamutWarning;
double m_adaptationState;
const KoColorSpace *m_proofingSpace;
};
......
......@@ -437,14 +437,14 @@ bool KoColorSpace::convertPixelsTo(const quint8 * src,
return true;
}
KoColorConversionTransformation * KoColorSpace::createProofingTransform(const KoColorSpace *dstColorSpace, const KoColorSpace *proofingSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning) const
KoColorConversionTransformation * KoColorSpace::createProofingTransform(const KoColorSpace *dstColorSpace, const KoColorSpace *proofingSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning, double adaptationState) const
{
if (!d->iccEngine) {
d->iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc");
}
if (!d->iccEngine) return 0;
return d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning);
return d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning, adaptationState);
}
bool KoColorSpace::proofPixelsTo(const quint8 *src,
......
......@@ -377,7 +377,7 @@ public:
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const;
quint8 *gamutWarning, double adaptationState) const;
/**
* @brief proofPixelsTo
* @param src
......@@ -389,6 +389,7 @@ public:
* @param proofingIntent the intent used for proofing.
* @param conversionFlags the conversion flags.
* @param gamutWarning the data() of a KoColor.
* @param adaptationState the state of adaptation, only affects absolute colorimetric.
* @return
*/
virtual bool proofPixelsTo(const quint8 * src,
......
......@@ -95,6 +95,9 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, QWidget *parent,
m_gamutWarning->setCurrentColor(m_proofingConfig->warningColor);
m_gamutWarning->setToolTip(i18n("Set color used for warning"));
m_page->gamutAlarm->setDefaultAction(m_gamutWarning);
m_page->sldAdaptationState->setMaximum(20);
m_page->sldAdaptationState->setMinimum(0);
m_page->sldAdaptationState->setValue((int)m_proofingConfig->adaptationState*20);
KisSignalCompressor *softProofConfigCompressor = new KisSignalCompressor(500, KisSignalCompressor::POSTPONE,this);
......@@ -102,6 +105,7 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, QWidget *parent,
connect(m_page->proofSpaceSelector, SIGNAL(colorSpaceChanged(const KoColorSpace*)), softProofConfigCompressor, SLOT(start()));
connect(m_page->cmbIntent, SIGNAL(currentIndexChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(m_page->ckbBlackPointComp, SIGNAL(stateChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(m_page->sldAdaptationState, SIGNAL(valueChanged(int)), softProofConfigCompressor, SLOT(start()));
connect(softProofConfigCompressor, SIGNAL(timeout()), this, SLOT(setProofingConfig()));
......@@ -150,7 +154,7 @@ void KisDlgImageProperties::setProofingConfig()
m_proofingConfig->proofingModel = m_page->proofSpaceSelector->currentColorSpace()->colorModelId().id();
m_proofingConfig->proofingDepth = "U8";//default to this
m_proofingConfig->warningColor = m_gamutWarning->currentKoColor();
m_proofingConfig->adaptationState = (double)m_page->sldAdaptationState->value()/20.0;
qDebug()<<"set proofing config in properties: "<<m_proofingConfig->proofingProfile;
m_image->setProofingConfiguration(m_proofingConfig);
}
......
......@@ -344,6 +344,9 @@ ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name)
m_gamutWarning->setToolTip(i18n("Set default color used for out of Gamut Warning"));
m_gamutWarning->setCurrentColor(proofingConfig->warningColor);
m_page->gamutAlarm->setDefaultAction(m_gamutWarning);
m_page->sldAdaptationState->setMaximum(20);
m_page->sldAdaptationState->setMinimum(0);
m_page->sldAdaptationState->setValue((int)proofingConfig->adaptationState*20);
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(proofingConfig->proofingModel,proofingConfig->proofingDepth,proofingConfig->proofingProfile);
m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
......@@ -446,6 +449,7 @@ void ColorSettingsTab::setDefault()
m_page->proofingSpaceSelector->setCurrentColorSpace(proofingSpace);
m_page->cmbProofingIntent->setCurrentIndex((int)proofingConfig->intent);
m_page->ckbProofBlackPoint->setChecked(proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation));
m_page->sldAdaptationState->setValue(0);
m_gamutWarning->setCurrentColor(proofingConfig->warningColor);
......@@ -987,7 +991,7 @@ bool KisDlgPreferences::editPreferences()
cfg.setWorkingColorSpace(dialog->m_colorSettings->m_page->cmbWorkingColorSpace->currentItem().id());
KisImageConfig cfgImage;
cfgImage.setDefaultProofingConfig(dialog->m_colorSettings->m_page->proofingSpaceSelector->currentColorSpace(), dialog->m_colorSettings->m_page->cmbProofingIntent->currentIndex(), dialog->m_colorSettings->m_page->ckbProofBlackPoint->isChecked(), dialog->m_colorSettings->m_gamutWarning->currentKoColor());
cfgImage.setDefaultProofingConfig(dialog->m_colorSettings->m_page->proofingSpaceSelector->currentColorSpace(), dialog->m_colorSettings->m_page->cmbProofingIntent->currentIndex(), dialog->m_colorSettings->m_page->ckbProofBlackPoint->isChecked(), dialog->m_colorSettings->m_gamutWarning->currentKoColor(), (double)dialog->m_colorSettings->m_page->sldAdaptationState->value()/20);
cfg.setUseBlackPointCompensation(dialog->m_colorSettings->m_page->chkBlackpoint->isChecked());
cfg.setAllowLCMSOptimization(dialog->m_colorSettings->m_page->chkAllowLCMSOptimization->isChecked());
cfg.setPasteBehaviour(dialog->m_colorSettings->m_pasteBehaviourGroup.checkedId());
......
......@@ -189,14 +189,41 @@
<string>Soft Proof Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="2">
<item row="5" column="1">
<widget class="QToolButton" name="gamutAlarm">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="3" column="0">
<widget class="QLabel" name="lblProofingIntent">
<property name="text">
<string>Proofing Rendering Intent:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="KisColorSpaceSelector" name="proofingSpaceSelector" native="true"/>
</item>
<item row="5" column="2" colspan="2">
<widget class="QCheckBox" name="ckbProofBlackPoint">
<property name="text">
<string>Back Point Compensation</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblGamutWarning">
<property name="text">
<string>Gamut Warning:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="cmbProofingIntent">
<item>
<property name="text">
......@@ -220,27 +247,20 @@
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Gamut Warning</string>
<item row="4" column="1" colspan="3">
<widget class="QSlider" name="sldAdaptationState">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="KisColorSpaceSelector" name="proofingSpaceSelector" native="true"/>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="ckbProofBlackPoint">
<widget class="QLabel" name="lblAdaptationState">
<property name="text">
<string>Back Point Compensation</string>
<string>Adaptation State:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Proofing Rendering Intent:</string>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
......
......@@ -227,34 +227,63 @@
<string>Softproofing</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="2">
<item row="3" column="1">
<widget class="QToolButton" name="gamutAlarm">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_4">
<item row="3" column="0">
<widget class="QLabel" name="lblGamutWarning">
<property name="text">
<string>Gamut Warning:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblAdaptationState">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Adaptation State:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QSlider" name="sldAdaptationState">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Set how much you wish to correct the adaptation state. This will affect how &lt;span style=&quot; font-style:italic;&quot;&gt;Absolute Colorimetric&lt;/span&gt; changes the whites of your image. In Layman's terms: how much do you wish to have the color management correct the paper-color to screen white while using &lt;span style=&quot; font-style:italic;&quot;&gt;Absolute Colorimetric&lt;/span&gt;?&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QCheckBox" name="ckbBlackPointComp">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Black Point compensation matches the darkest color of the source device to the darkest color of the destination device. Relative Colorimetric without Black Point Compensation will show the difference between the darkest values. With blackpoint compensation, black is black.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Black Point Compenstation</string>
<string>Black Point Compensation</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="0" column="0" colspan="4">
<widget class="KisColorSpaceSelector" name="proofSpaceSelector" native="true"/>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Rendering Intent</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="1">
<item row="0" column="0" colspan="2">
<widget class="QComboBox" name="cmbIntent">
<property name="currentIndex">
<number>0</number>
......@@ -284,9 +313,6 @@
</layout>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="KisColorSpaceSelector" name="proofSpaceSelector" native="true"/>
</item>
</layout>
</widget>
</widget>
......
......@@ -281,6 +281,10 @@ KisImageWSP KisKraLoader::loadXML(const KoXmlElement& element)
proofingConfig->intent = (KoColorConversionTransformation::Intent) KisDomUtils::toInt(attr);
}
if (!(attr = element.attribute(PROOFINGADAPTATIONSTATE)).isNull()) {
proofingConfig->adaptationState = KisDomUtils::toDouble(attr);
}
if (m_d->document) {
image = new KisImage(m_d->document->createUndoStore(), width, height, cs, name);
}
......
......@@ -108,6 +108,7 @@ QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageWSP image)
imageElement.setAttribute(PROOFINGMODEL, KisDomUtils::toString(image->proofingConfiguration()->proofingModel));
imageElement.setAttribute(PROOFINGDEPTH, KisDomUtils::toString(image->proofingConfiguration()->proofingDepth));
imageElement.setAttribute(PROOFINGINTENT, KisDomUtils::toString(image->proofingConfiguration()->intent));
imageElement.setAttribute(PROOFINGADAPTATIONSTATE, KisDomUtils::toString(image->proofingConfiguration()->adaptationState));
quint32 count = 1; // We don't save the root layer, but it does count
KisSaveXmlVisitor visitor(doc, imageElement, count, m_d->doc->url().toLocalFile(), true);
......
......@@ -115,6 +115,7 @@ const QString PROOFINGMODEL = "proofing-model";
const QString PROOFINGDEPTH = "proofing-depth";
const QString PROOFINGINTENT = "proofing-intent";
const QString PROOFINGWARNINGCOLOR ="ProofingWarningColor";
const QString PROOFINGADAPTATIONSTATE = "proofing-adaptation-state";
const QString ICCPROOFINGPROFILE ="icc-proofing-profile";
const QString CANVASPROJECTIONCOLOR = "ProjectionBackgroundColor";
const QString COLORBYTEDATA = "ColorData";
......
......@@ -332,7 +332,7 @@ KisOpenGLUpdateInfoSP KisOpenGLImageTextures::updateCacheImpl(const QRect& rect,
//create transform
if (m_createNewProofingTransform) {
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(m_proofingConfig->proofingModel,m_proofingConfig->proofingDepth,m_proofingConfig->proofingProfile);
m_proofingTransform = tileInfo->generateProofingTransform(dstCS, proofingSpace, m_renderingIntent, m_proofingConfig->intent, m_proofingConfig->conversionFlags, m_proofingConfig->warningColor);
m_proofingTransform = tileInfo->generateProofingTransform(dstCS, proofingSpace, m_renderingIntent, m_proofingConfig->intent, m_proofingConfig->conversionFlags, m_proofingConfig->warningColor, m_proofingConfig->adaptationState);
m_createNewProofingTransform = false;
}
......
......@@ -232,9 +232,10 @@ public:
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
KoColor gamutWarning)
KoColor gamutWarning,
double adaptationState)
{
return m_patchColorSpace->createProofingTransform(dstCS, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning.data());
return m_patchColorSpace->createProofingTransform(dstCS, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning.data(), adaptationState);
}
inline quint8* data() const {
......
......@@ -103,9 +103,10 @@ public:
Intent renderingIntent,
Intent proofingIntent,
ConversionFlags conversionFlags,
quint8 *gamutWarning
quint8 *gamutWarning,
double adaptationState
)
: KoColorProofingConversionTransformation(srcCs, dstCs, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning)
: KoColorProofingConversionTransformation(srcCs, dstCs, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning, adaptationState)
, m_transform(0)
{
Q_ASSERT(srcCs);
......@@ -127,6 +128,7 @@ public:
alarm[1] = (cmsUInt16Number)gamutWarning[1]*256;
alarm[2] = (cmsUInt16Number)gamutWarning[0]*256;
cmsSetAlarmCodes(alarm);
cmsSetAdaptationState(adaptationState);
m_transform = cmsCreateProofingTransform(srcProfile->lcmsProfile(),
srcColorSpaceType,
......@@ -136,6 +138,7 @@ public:
renderingIntent,
proofingIntent,
conversionFlags);
cmsSetAdaptationState(1);
Q_ASSERT(m_transform);
}
......@@ -153,6 +156,7 @@ public:
qint32 srcPixelSize = srcColorSpace()->pixelSize();
qint32 dstPixelSize = dstColorSpace()->pixelSize();
//cmsSetAdaptationState(0);
cmsDoTransform(m_transform, const_cast<quint8 *>(src), dst, numPixels);
// Lcms does nothing to the destination alpha channel so we must convert that manually.
......@@ -164,6 +168,7 @@ public:
dst += dstPixelSize;
numPixels--;
}
//cmsSetAdaptationState(1);
}
private:
......@@ -242,7 +247,8 @@ KoColorProofingConversionTransformation *IccColorSpaceEngine::createColorProofin
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
quint8 *gamutWarning,
double adaptationState) const
{
Q_ASSERT(srcColorSpace);
Q_ASSERT(dstColorSpace);
......@@ -250,7 +256,8 @@ 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, proofingIntent, conversionFlags, gamutWarning
dynamic_cast<const IccColorProfile *>(dstColorSpace->profile())->asLcms(), proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning,
adaptationState
);
}
......
......@@ -37,7 +37,7 @@ public:
const KoColorSpace *dstColorSpace,
const KoColorSpace *proofingSpace,
KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning) const;
KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning, double adaptationState) 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