From 93d442f8025d80c16eb5dfccb0e16de3a9f365fb Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Fri, 15 Jun 2018 14:16:37 +0200 Subject: [PATCH] increased precision of the channel mixer (allow 1 decimal figure) --- rtengine/improcfun.cc | 18 +++++++------- rtengine/procparams.cc | 13 +++++++--- rtgui/chmixer.cc | 54 +++++++++++++++++++++++------------------- rtgui/ppversion.h | 4 +++- 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index e7eac2b09..cf1dd5add 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -2255,15 +2255,15 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float Balan = float (params->colorToning.balance); - float chMixRR = float (params->chmixer.red[0]); - float chMixRG = float (params->chmixer.red[1]); - float chMixRB = float (params->chmixer.red[2]); - float chMixGR = float (params->chmixer.green[0]); - float chMixGG = float (params->chmixer.green[1]); - float chMixGB = float (params->chmixer.green[2]); - float chMixBR = float (params->chmixer.blue[0]); - float chMixBG = float (params->chmixer.blue[1]); - float chMixBB = float (params->chmixer.blue[2]); + float chMixRR = float (params->chmixer.red[0])/10.f; + float chMixRG = float (params->chmixer.red[1])/10.f; + float chMixRB = float (params->chmixer.red[2])/10.f; + float chMixGR = float (params->chmixer.green[0])/10.f; + float chMixGG = float (params->chmixer.green[1])/10.f; + float chMixGB = float (params->chmixer.green[2])/10.f; + float chMixBR = float (params->chmixer.blue[0])/10.f; + float chMixBG = float (params->chmixer.blue[1])/10.f; + float chMixBB = float (params->chmixer.blue[2])/10.f; bool blackwhite = params->blackwhite.enabled; bool complem = params->blackwhite.enabledcc; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 344804f99..a704a8a9c 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1787,19 +1787,19 @@ bool VignettingParams::operator !=(const VignettingParams& other) const ChannelMixerParams::ChannelMixerParams() : enabled(false), red{ - 100, + 1000, 0, 0 }, green{ 0, - 100, + 1000, 0 }, blue{ 0, 0, - 100 + 1000 } { } @@ -3523,6 +3523,13 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) memcpy (chmixer.green, gmix.data(), 3 * sizeof (int)); memcpy (chmixer.blue, bmix.data(), 3 * sizeof (int)); } + if (ppVersion < 338) { + for (int i = 0; i < 3; ++i) { + chmixer.red[i] *= 10; + chmixer.green[i] *= 10; + chmixer.blue[i] *= 10; + } + } if (pedited) { pedited->chmixer.red[0] = pedited->chmixer.red[1] = pedited->chmixer.red[2] = true; diff --git a/rtgui/chmixer.cc b/rtgui/chmixer.cc index c6c098883..452dd068d 100644 --- a/rtgui/chmixer.cc +++ b/rtgui/chmixer.cc @@ -39,9 +39,9 @@ ChMixer::ChMixer (): FoldableToolPanel(this, "chmixer", M("TP_CHMIXER_LABEL"), f rlabel->set_markup (Glib::ustring("\t") + M("TP_CHMIXER_RED") + Glib::ustring(":")); rlabel->set_alignment(Gtk::ALIGN_START); - red[0] = Gtk::manage (new Adjuster ("", -200, 200, 1, 100, imgIcon[0])); - red[1] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[1])); - red[2] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[2])); + red[0] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 100, imgIcon[0])); + red[1] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[1])); + red[2] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[2])); Gtk::HSeparator* rsep = Gtk::manage (new Gtk::HSeparator ()); @@ -58,9 +58,9 @@ ChMixer::ChMixer (): FoldableToolPanel(this, "chmixer", M("TP_CHMIXER_LABEL"), f glabel->set_alignment(Gtk::ALIGN_START); - green[0] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[3])); - green[1] = Gtk::manage (new Adjuster ("", -200, 200, 1, 100, imgIcon[4])); - green[2] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[5])); + green[0] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[3])); + green[1] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 100, imgIcon[4])); + green[2] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[5])); Gtk::HSeparator* gsep = Gtk::manage (new Gtk::HSeparator ()); @@ -75,9 +75,9 @@ ChMixer::ChMixer (): FoldableToolPanel(this, "chmixer", M("TP_CHMIXER_LABEL"), f Gtk::Label* blabel = Gtk::manage (new Gtk::Label ()); blabel->set_markup (Glib::ustring("\t") + M("TP_CHMIXER_BLUE") + Glib::ustring(":")); blabel->set_alignment(Gtk::ALIGN_START); - blue[0] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[6])); - blue[1] = Gtk::manage (new Adjuster ("", -200, 200, 1, 0, imgIcon[7])); - blue[2] = Gtk::manage (new Adjuster ("", -200, 200, 1, 100, imgIcon[8])); + blue[0] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[6])); + blue[1] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 0, imgIcon[7])); + blue[2] = Gtk::manage (new Adjuster ("", -200, 200, 0.1, 100, imgIcon[8])); for (int i = 0; i < 3; i++) { red[i]->setAdjusterListener (this); @@ -111,9 +111,9 @@ void ChMixer::read (const ProcParams* pp, const ParamsEdited* pedited) } for (int i = 0; i < 3; i++) { - red[i]->setValue (pp->chmixer.red[i]); - green[i]->setValue (pp->chmixer.green[i]); - blue[i]->setValue (pp->chmixer.blue[i]); + red[i]->setValue (pp->chmixer.red[i] / 10.0); + green[i]->setValue (pp->chmixer.green[i] / 10.0); + blue[i]->setValue (pp->chmixer.blue[i] / 10.0); } enableListener (); @@ -123,9 +123,9 @@ void ChMixer::write (ProcParams* pp, ParamsEdited* pedited) { for (int i = 0; i < 3; i++) { - pp->chmixer.red[i] = (int) red[i]->getValue (); - pp->chmixer.green[i] = (int) green[i]->getValue (); - pp->chmixer.blue[i] = (int) blue[i]->getValue (); + pp->chmixer.red[i] = red[i]->getValue() * 10; + pp->chmixer.green[i] = green[i]->getValue() * 10; + pp->chmixer.blue[i] = blue[i]->getValue() * 10; } pp->chmixer.enabled = getEnabled(); @@ -143,9 +143,9 @@ void ChMixer::setDefaults (const ProcParams* defParams, const ParamsEdited* pedi { for (int i = 0; i < 3; i++) { - red[i]->setDefault (defParams->chmixer.red[i]); - green[i]->setDefault (defParams->chmixer.green[i]); - blue[i]->setDefault (defParams->chmixer.blue[i]); + red[i]->setDefault (defParams->chmixer.red[i] / 10.f); + green[i]->setDefault (defParams->chmixer.green[i] / 10.f); + blue[i]->setDefault (defParams->chmixer.blue[i] / 10.f); } if (pedited) @@ -167,9 +167,9 @@ void ChMixer::adjusterChanged (Adjuster* a, double newval) if (listener && getEnabled()) { Glib::ustring descr = Glib::ustring::compose ("R=%1,%2,%3\nG=%4,%5,%6\nB=%7,%8,%9", - (int)red[0]->getValue(), (int)red[1]->getValue(), (int)red[2]->getValue(), - (int)green[0]->getValue(), (int)green[1]->getValue(), (int)green[2]->getValue(), - (int)blue[0]->getValue(), (int)blue[1]->getValue(), (int)blue[2]->getValue()); + red[0]->getValue(), red[1]->getValue(), red[2]->getValue(), + green[0]->getValue(), green[1]->getValue(), green[2]->getValue(), + blue[0]->getValue(), blue[1]->getValue(), blue[2]->getValue()); listener->panelChanged (EvChMixer, descr); } } @@ -215,8 +215,14 @@ void ChMixer::trimValues (rtengine::procparams::ProcParams* pp) { for (int i = 0; i < 3; i++) { - red[i]->trimValue(pp->chmixer.red[i]); - green[i]->trimValue(pp->chmixer.green[i]); - blue[i]->trimValue(pp->chmixer.blue[i]); + double r = pp->chmixer.red[i] / 10.0; + double g = pp->chmixer.green[i] / 10.0; + double b = pp->chmixer.blue[i] / 10.0; + red[i]->trimValue(r); + green[i]->trimValue(g); + blue[i]->trimValue(b); + pp->chmixer.red[i] = r * 10; + pp->chmixer.green[i] = g * 10; + pp->chmixer.blue[i] = b * 10; } } diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index 051dc6e2c..ac12e97d8 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -1,11 +1,13 @@ #pragma once // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 337 +#define PPVERSION 338 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes + 338 2018-06-15 + increased precision for the channel mixer 337 2018-06-13 new scales for the LabGrid color toning parameters 336 2018-06-01