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++

Let Krita generate a Rec2100 pq profile with dummy curve and proper CICP.

Wolthera van Hövell tot Westerflierd7cda34b6106
diff --git a/plugins/color/lcms2engine/LcmsEnginePlugin.cpp b/plugins/color/lcms2engine/LcmsEnginePlugin.cpp
index ccfb69901e..d654cdeca8 100644
--- a/plugins/color/lcms2engine/LcmsEnginePlugin.cpp
+++ b/plugins/color/lcms2engine/LcmsEnginePlugin.cpp
@@ -167,6 +167,11 @@ LcmsEnginePlugin::LcmsEnginePlugin(QObject *parent, const QVariantList &)
KoColorProfile *rgbProfile = LcmsColorProfileContainer::createFromLcmsProfile(cmsCreate_sRGBProfile());
registry->addProfile(rgbProfile);
+ // TODO: decide whether we want to do it like this.
+ QVector<double> rec2020Col;
+ KoColorProfile *rec2100pq = new IccColorProfile(rec2020Col, PRIMARIES_ITU_R_BT_2020_2_AND_2100_0, TRC_ITU_R_BT_2100_0_PQ);
+ registry->addProfile(rec2100pq);
+
registry->add(new LcmsRGBP2020PQColorSpaceFactoryWrapper<RgbU8ColorSpaceFactory>());
registry->add(new LcmsRGBP2020PQColorSpaceFactoryWrapper<RgbU16ColorSpaceFactory>());
#ifdef HAVE_LCMS24
diff --git a/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp b/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp
index 55d039751e..dfebc5769c 100644
--- a/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp
+++ b/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp
@@ -688,6 +688,17 @@ bool LcmsColorProfileContainer::compareTRC(TransferCharacteristics characteristi
return true;
}
+#include <KoColorTransferFunctions.h>
+cmsToneCurve *perceptualQuantizerDummy() {
+ cmsFloat32Number CurveVals[1024];
+ for (int i = 0; i < 1024; i++) {
+ float val = float(i)/1023.0;
+ /// IMPORTANT: 125.0 is the maximum output of the curve and is controlled by the diffuse white!
+ CurveVals[i] = (removeSmpte2048Curve(val)/125.0);
+ }
+ return cmsBuildTabulatedToneCurveFloat(NULL, 1024, CurveVals);
+}
+
cmsToneCurve *LcmsColorProfileContainer::transferFunction(TransferCharacteristics transferFunction)
{
cmsToneCurve *mainCurve;
@@ -762,10 +773,11 @@ cmsToneCurve *LcmsColorProfileContainer::transferFunction(TransferCharacteristic
case TRC_LAB_L:
mainCurve = cmsBuildParametricToneCurve(NULL, 4, labl_parameters);
break;
+ case TRC_ITU_R_BT_2100_0_PQ:
+ return perceptualQuantizerDummy();
+ break;
case TRC_SMPTE_ST_428_1:
// Requires an a*X^y construction, not possible.
- case TRC_ITU_R_BT_2100_0_PQ:
- // Perceptual Quantizer
case TRC_ITU_R_BT_2100_0_HLG:
// Hybrid log gamma.
qWarning() << "Cannot generate an icc profile with this transfer function, will generate a linear profile";