[graphics/krita] plugins/dockers/smallcolorselector: Fix small color selector to take the hdr reference white of pq profiles into account.

Wolthera van Hövell <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 723f631e8e41dbefa6ea9c83eecb16d37572f387 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 16/07/2026 at 16:26.
Pushed by woltherav into branch 'master'.

Fix small color selector to take the hdr reference white of pq profiles into account.

M  +8    -3    plugins/dockers/smallcolorselector/kis_small_color_widget.cc

https://invent.kde.org/graphics/krita/-/commit/723f631e8e41dbefa6ea9c83eecb16d37572f387

diff --git a/plugins/dockers/smallcolorselector/kis_small_color_widget.cc b/plugins/dockers/smallcolorselector/kis_small_color_widget.cc
index 05235630f53..63c33a09320 100644
--- a/plugins/dockers/smallcolorselector/kis_small_color_widget.cc
+++ b/plugins/dockers/smallcolorselector/kis_small_color_widget.cc
@@ -54,6 +54,7 @@ struct KisSmallColorWidget::Private {
     int huePreferredHeight = 32;
     KisSliderSpinBox *dynamicRange = 0;
     qreal currentRelativeDynamicRange = 1.0;
+    qreal currenReferenceWhite = 80.0;
     KisDisplayColorConverter *displayColorConverter = KisDisplayColorConverter::dumbConverterInstance();
     KisSignalAutoConnectionsStore colorConverterConnections;
     bool hasHDR = false;
@@ -182,7 +183,7 @@ KisSmallColorWidget::KisSmallColorWidget(QWidget* parent)
         d->dynamicRange->setSingleStep(1);
         d->dynamicRange->setPageStep(100);
         d->dynamicRange->setSuffix("cd/m²");
-        d->dynamicRange->setValue(80.0 * d->currentRelativeDynamicRange);
+        d->dynamicRange->setValue(d->currenReferenceWhite * d->currentRelativeDynamicRange);
         connect(d->dynamicRange, SIGNAL(valueChanged(int)), SLOT(slotInitiateUpdateDynamicRange(int)));
     }
 
@@ -268,7 +269,7 @@ void KisSmallColorWidget::setColor(const KoColor &color)
         if (rangeCoeff < r || rangeCoeff < g || rangeCoeff < b) {
             rangeCoeff = std::max({r, g, b}) * 1.10f;
 
-            const int newMaxLuminance = qRound(80.0 * rangeCoeff);
+            const int newMaxLuminance = qRound(d->currenReferenceWhite * rangeCoeff);
             updateDynamicRange(newMaxLuminance);
             d->dynamicRange->setValue(newMaxLuminance);
         }
@@ -433,7 +434,7 @@ void KisSmallColorWidget::slotInitiateUpdateDynamicRange(int maxLuminance)
 void KisSmallColorWidget::updateDynamicRange(int maxLuminance)
 {
     const qreal oldRange = d->currentRelativeDynamicRange;
-    const qreal newRange = qreal(maxLuminance) / 80.0;
+    const qreal newRange = qreal(maxLuminance) / d->currenReferenceWhite;
 
     if (qFuzzyCompare(oldRange, newRange)) return;
 
@@ -490,6 +491,10 @@ void KisSmallColorWidget::slotDisplayConfigurationChanged()
                  cs->colorDepthId() == Float32BitsColorDepthID ||
                  cs->colorDepthId() == Float64BitsColorDepthID ||
                  cs->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ);
+
+        if (d->hasHDR) {
+            d->currenReferenceWhite = cs->profile()->hdrReferenceWhite().value_or(80.0);
+        }
     }
 
     if (d->dynamicRange) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.