From 3fc7c2596521a3dc40b3c951200dcb9520681cbc Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 19 Jan 2019 19:22:45 +0100 Subject: [PATCH] softproof not working when no printer profile is set (no sRGB preview on wide gamut screens), fixes #5143 --- rtengine/improcfun.cc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index bf35bee70..404229d10 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -338,14 +338,39 @@ void ImProcFunctions::updateColorProfiles (const Glib::ustring& monitorProfile, // flags |= cmsFLAGS_GAMUTCHECK; // } + const auto make_gamma_table = + [](cmsHPROFILE prof, cmsTagSignature tag) -> void + { + cmsToneCurve *tc = static_cast(cmsReadTag(prof, tag)); + if (tc) { + const cmsUInt16Number *table = cmsGetToneCurveEstimatedTable(tc); + cmsToneCurve *tc16 = cmsBuildTabulatedToneCurve16(nullptr, cmsGetToneCurveEstimatedTableEntries(tc), table); + if (tc16) { + cmsWriteTag(prof, tag, tc16); + cmsFreeToneCurve(tc16); + } + } + }; + + cmsHPROFILE softproof = ProfileContent(oprof).toProfile(); + if (softproof) { + make_gamma_table(softproof, cmsSigRedTRCTag); + make_gamma_table(softproof, cmsSigGreenTRCTag); + make_gamma_table(softproof, cmsSigBlueTRCTag); + } + monitorTransform = cmsCreateProofingTransform ( iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_FLT, - oprof, + softproof, //oprof, monitorIntent, outIntent, flags ); + if (softproof) { + cmsCloseProfile(softproof); + } + if (monitorTransform) { softProofCreated = true; }