[graphics/krita] /: Test both the presence of hdr reference white and whether it is a PQ profile.

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

Test both the presence of hdr reference white and whether it is a PQ profile.

M  +2    -2    libs/image/kis_image.cc
M  +1    -1    plugins/impex/libkra/kis_kra_saver.cpp

https://invent.kde.org/graphics/krita/-/commit/3b07d8f0704c19dc5b889f9a2c80b0feaacb6ab1

diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index 80600376811..67f29370044 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -2118,7 +2118,7 @@ void KisImage::setColorVolumeInformation(const std::optional<KisColorVolumeInfor
 
 std::optional<double> KisImage::diffuseWhiteLightLevel() const
 {
-    if (m_d->colorSpace->profile()->hdrReferenceWhite()) {
+    if (m_d->colorSpace->profile()->hdrReferenceWhite() && m_d->colorSpace->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ) {
         return m_d->colorSpace->profile()->hdrReferenceWhite();
     }
     return m_d->diffuseWhiteLightLevel;
@@ -2126,7 +2126,7 @@ std::optional<double> KisImage::diffuseWhiteLightLevel() const
 
 void KisImage::setDiffuseWhiteLightLevel(const std::optional<double> cdm2)
 {
-    if (m_d->colorSpace->profile()->hdrReferenceWhite()) {
+    if (m_d->colorSpace->profile()->hdrReferenceWhite() && m_d->colorSpace->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ) {
         qWarning() << "Cannot set diffuse white on image: profile provides the diffuse white for this image.";
         return;
     }
diff --git a/plugins/impex/libkra/kis_kra_saver.cpp b/plugins/impex/libkra/kis_kra_saver.cpp
index e3c7f379ef2..eccd099e00a 100644
--- a/plugins/impex/libkra/kis_kra_saver.cpp
+++ b/plugins/impex/libkra/kis_kra_saver.cpp
@@ -709,7 +709,7 @@ void KisKraSaver::saveHDRMetadata(QDomDocument &doc, QDomElement &element, KisIm
         return;
     }
     QDomElement hdr = doc.createElement(HDRMETADATA);
-    if (image->diffuseWhiteLightLevel() && !image->colorSpace()->profile()->hdrReferenceWhite()) {
+    if (image->diffuseWhiteLightLevel() && !(image->colorSpace()->profile()->hdrReferenceWhite() && image->colorSpace()->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ)) {
         KisDomUtils::saveValue(&hdr, DIFFUSEWHITE, *image->diffuseWhiteLightLevel());
     }
     if (image->relativeContentLightLevelInformation()) {
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.