From ad7f47804b8592d04de46eb5f0be01490c608015 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 24 Nov 2018 13:01:18 +0100 Subject: [PATCH] If a custom TRC is set, it is applied after every edit, fixes #5023 --- rtengine/dcrop.cc | 38 ++++++++++++++++++----------------- rtengine/improccoordinator.cc | 8 ++++++-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 81cc576c9..7854dfb81 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -808,56 +808,58 @@ void Crop::update(int todo) } - if (todo & (M_AUTOEXP | M_RGBCURVE)) { + if (todo & M_RGBCURVE) { + Imagefloat *workingCrop = baseCrop; + if (params.icm.workingTRC == "Custom") { //exec TRC IN free - Glib::ustring profile; - profile = params.icm.workingProfile; + const Glib::ustring profile = params.icm.workingProfile; if (profile == "sRGB" || profile == "Adobe RGB" || profile == "ProPhoto" || profile == "WideGamut" || profile == "BruceRGB" || profile == "Beta RGB" || profile == "BestRGB" || profile == "Rec2020" || profile == "ACESp0" || profile == "ACESp1") { - + int cw = baseCrop->getWidth(); + int ch = baseCrop->getHeight(); + workingCrop = new Imagefloat(cw, ch); + baseCrop->copyData(workingCrop); //first put gamma TRC to 1 - int cw = baseCrop->getWidth(); - int ch = baseCrop->getHeight(); - Imagefloat* readyImg0 = parent->ipf.workingtrc(baseCrop, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310); + Imagefloat* readyImg0 = parent->ipf.workingtrc(workingCrop, cw, ch, -5, params.icm.workingProfile, 2.4, 12.92310); #pragma omp parallel for for (int row = 0; row < ch; row++) { for (int col = 0; col < cw; col++) { - baseCrop->r(row, col) = (float)readyImg0->r(row, col); - baseCrop->g(row, col) = (float)readyImg0->g(row, col); - baseCrop->b(row, col) = (float)readyImg0->b(row, col); + workingCrop->r(row, col) = (float)readyImg0->r(row, col); + workingCrop->g(row, col) = (float)readyImg0->g(row, col); + workingCrop->b(row, col) = (float)readyImg0->b(row, col); } } delete readyImg0; //adjust gamma TRC - Imagefloat* readyImg = parent->ipf.workingtrc(baseCrop, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope); + Imagefloat* readyImg = parent->ipf.workingtrc(workingCrop, cw, ch, 5, params.icm.workingProfile, params.icm.workingTRCGamma, params.icm.workingTRCSlope); #pragma omp parallel for for (int row = 0; row < ch; row++) { for (int col = 0; col < cw; col++) { - baseCrop->r(row, col) = (float)readyImg->r(row, col); - baseCrop->g(row, col) = (float)readyImg->g(row, col); - baseCrop->b(row, col) = (float)readyImg->b(row, col); + workingCrop->r(row, col) = (float)readyImg->r(row, col); + workingCrop->g(row, col) = (float)readyImg->g(row, col); + workingCrop->b(row, col) = (float)readyImg->b(row, col); } } delete readyImg; } } - } - - if (todo & M_RGBCURVE) { double rrm, ggm, bbm; DCPProfile::ApplyState as; DCPProfile *dcpProf = parent->imgsrc->getDCP(params.icm, as); LUTu histToneCurve; - parent->ipf.rgbProc (baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, + parent->ipf.rgbProc (workingCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, params.toneCurve.saturation, parent->rCurve, parent->gCurve, parent->bCurve, parent->colourToningSatLimit, parent->colourToningSatLimitOpacity, parent->ctColorCurve, parent->ctOpacityCurve, parent->opautili, parent->clToningcurve, parent->cl2Toningcurve, parent->customToneCurve1, parent->customToneCurve2, parent->beforeToneCurveBW, parent->afterToneCurveBW, rrm, ggm, bbm, parent->bwAutoR, parent->bwAutoG, parent->bwAutoB, dcpProf, as, histToneCurve); + if (workingCrop != baseCrop) { + delete workingCrop; + } } /*xref=000;yref=000; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 2d6db3dd9..d76ccda27 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -506,8 +506,12 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) if (todo & (M_AUTOEXP | M_RGBCURVE)) { if (params.icm.workingTRC == "Custom") { //exec TRC IN free - Glib::ustring profile; - profile = params.icm.workingProfile; + if (oprevi == orig_prev) { + oprevi = new Imagefloat(pW, pH); + orig_prev->copyData(oprevi); + } + + Glib::ustring profile = params.icm.workingProfile; if (profile == "sRGB" || profile == "Adobe RGB" || profile == "ProPhoto" || profile == "WideGamut" || profile == "BruceRGB" || profile == "Beta RGB" || profile == "BestRGB" || profile == "Rec2020" || profile == "ACESp0" || profile == "ACESp1") { int cw = oprevi->getWidth();