Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Save and load the calculation type.

Wolthera van Hövell tot Westerflierdae96fdbb63f
diff --git a/libs/image/kis_hdr_metadata.h b/libs/image/kis_hdr_metadata.h
index 8c59463434..ad22c30e65 100644
--- a/libs/image/kis_hdr_metadata.h
+++ b/libs/image/kis_hdr_metadata.h
@@ -32,7 +32,7 @@ struct KisRelativeContentLightLevelInformation: public boost::equality_comparabl
RGBComponent ///< Calculate luminance on the RGB components if possible.
};
- CalculationType type;
+ CalculationType type = XYZLuminance;
bool operator==(const KisRelativeContentLightLevelInformation & other) const {
return qFuzzyCompare(maxContentLightLevel, other.maxContentLightLevel)
diff --git a/libs/image/processing/KisContentLightLevelProcessingVistor.cpp b/libs/image/processing/KisContentLightLevelProcessingVistor.cpp
index 61fb93349e..7f35235637 100644
--- a/libs/image/processing/KisContentLightLevelProcessingVistor.cpp
+++ b/libs/image/processing/KisContentLightLevelProcessingVistor.cpp
@@ -49,6 +49,7 @@ KisRelativeContentLightLevelInformation KisContentLightLevelProcessingVistor::co
total += c.maxFrameAverageLightLevel;
}
clli.maxFrameAverageLightLevel = d->clli.isEmpty()? 0.0: total / d->clli.size();
+ clli.type = d->type;
return clli;
}
@@ -116,6 +117,6 @@ KisRelativeContentLightLevelInformation KisContentLightLevelProcessingVistor::ca
}
}
- clli.maxFrameAverageLightLevel = average / divider;
+ clli.maxFrameAverageLightLevel = divider > 0? average / divider: 0;
return clli;
}
diff --git a/plugins/impex/libkra/kis_kra_loader.cpp b/plugins/impex/libkra/kis_kra_loader.cpp
index 67108e7c65..43a73fa111 100644
--- a/plugins/impex/libkra/kis_kra_loader.cpp
+++ b/plugins/impex/libkra/kis_kra_loader.cpp
@@ -1561,6 +1561,14 @@ void KisKraLoader::loadHDRMetadata(const QDomElement &elem, KisImageSP image)
KisRelativeContentLightLevelInformation clli;
clli.maxContentLightLevel = child.attribute(MAXCLL, "0.0").toDouble();
clli.maxFrameAverageLightLevel = child.attribute(MAXFALL, "0.0").toDouble();
+ const QString type = child.attribute(CLLI_CALCTYPE);
+ if (type == CLLI_CALC_RGB_XYZ_FALLBACK) {
+ clli.type = KisRelativeContentLightLevelInformation::RGBComponent;
+ } else if (type == CLLI_CALC_Rec2020) {
+ clli.type = KisRelativeContentLightLevelInformation::Rec2020Component;
+ } else {
+ clli.type = KisRelativeContentLightLevelInformation::XYZLuminance;
+ }
std::optional<KisRelativeContentLightLevelInformation> ci = std::make_optional(clli);
image->setRelativeContentLightLevelInformation(ci);
}
diff --git a/plugins/impex/libkra/kis_kra_saver.cpp b/plugins/impex/libkra/kis_kra_saver.cpp
index 9aac6b2860..1db647a634 100644
--- a/plugins/impex/libkra/kis_kra_saver.cpp
+++ b/plugins/impex/libkra/kis_kra_saver.cpp
@@ -717,6 +717,13 @@ void KisKraSaver::saveHDRMetadata(QDomDocument &doc, QDomElement &element, KisIm
QDomElement clli = doc.createElement(CONTENTLIGHTLEVEL);
clli.setAttribute(MAXCLL, KisDomUtils::toString(c.maxContentLightLevel));
clli.setAttribute(MAXFALL, KisDomUtils::toString(c.maxFrameAverageLightLevel));
+ if (c.type == KisRelativeContentLightLevelInformation::XYZLuminance) {
+ clli.setAttribute(CLLI_CALCTYPE, CLLI_CALC_XYZY);
+ } else if (c.type == KisRelativeContentLightLevelInformation::Rec2020Component) {
+ clli.setAttribute(CLLI_CALCTYPE, CLLI_CALC_Rec2020);
+ } else if (c.type == KisRelativeContentLightLevelInformation::RGBComponent) {
+ clli.setAttribute(CLLI_CALCTYPE, CLLI_CALC_RGB_XYZ_FALLBACK);
+ }
hdr.appendChild(clli);
}
if (image->colorVolumeInformation()) {
diff --git a/plugins/impex/libkra/kis_kra_tags.h b/plugins/impex/libkra/kis_kra_tags.h
index 698ebae211..f1c177af42 100644
--- a/plugins/impex/libkra/kis_kra_tags.h
+++ b/plugins/impex/libkra/kis_kra_tags.h
@@ -144,6 +144,10 @@ const QString HDRMETADATA = "HdrMetadata";
const QString CONTENTLIGHTLEVEL = "ContentLightLevel";
const QString MAXCLL = "max-content-light-level";
const QString MAXFALL = "max-avarage-frame-light-level";
+const QString CLLI_CALCTYPE = "content-light-level-calculation-type";
+const QString CLLI_CALC_XYZY = "XYZLuminance";
+const QString CLLI_CALC_Rec2020 = "Rec2020Component";
+const QString CLLI_CALC_RGB_XYZ_FALLBACK = "RGBComponent";
const QString DIFFUSEWHITE = "DiffuseWhite";
const QString COLORVOLUME = "ColorVolume";
const QString COLORVOLUMERED = "Red";