From 294f16c7415d3b9ae3c4305ec8e64c19ee022e87 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Thu, 25 Aug 2016 19:28:05 +0200 Subject: [PATCH 1/9] RGB Curves Luminosity mode: ~ 40% speedup --- rtengine/color.cc | 6 +-- rtengine/improcfun.cc | 106 ++++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 69 deletions(-) diff --git a/rtengine/color.cc b/rtengine/color.cc index c6f69d968..60d355b26 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -2137,7 +2137,7 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chprov1, float &R, float &G, float &B, const double wip[3][3], const bool isHLEnabled, const float lowerCoef, const float higherCoef) #endif { - const float ClipLevel = 65535.0f; + constexpr float ClipLevel = 65535.0f; bool inGamut; #ifdef _DEBUG neg = false, more_rgb = false; @@ -2146,7 +2146,6 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr do { inGamut = true; - //Lprov1=LL; float aprov1 = Chprov1 * sincosval.y; float bprov1 = Chprov1 * sincosval.x; @@ -2156,9 +2155,8 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr float fz = fy - (0.005f * bprov1); float x_ = 65535.0f * f2xyz(fx) * D50x; - // float y_ = 65535.0f * f2xyz(fy); float z_ = 65535.0f * f2xyz(fz) * D50z; - float y_ = (Lprov1 > epskap) ? 65535.0 * fy * fy * fy : 65535.0 * Lprov1 / kappa; + float y_ = (Lprov1 > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * Lprov1 / kappa; xyz2rgb(x_, y_, z_, R, G, B, wip); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 9bbdb022f..112ef9826 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -40,7 +40,7 @@ #include "improccoordinator.h" #include "clutstore.h" #include "ciecam02.h" -//#define BENCHMARK +#define BENCHMARK #include "StopWatch.h" #include "../rtgui/ppversion.h" #include "../rtgui/guiutils.h" @@ -2977,19 +2977,19 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer TMatrix wprof = iccStore->workingSpaceMatrix (params->icm.working); TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working); - double toxyz[3][3] = { + float toxyz[3][3] = { { - ( wprof[0][0] / Color::D50x), - ( wprof[0][1] / Color::D50x), - ( wprof[0][2] / Color::D50x) + static_cast( wprof[0][0] / Color::D50x), + static_cast( wprof[0][1] / Color::D50x), + static_cast( wprof[0][2] / Color::D50x) }, { - ( wprof[1][0]), - ( wprof[1][1]), - ( wprof[1][2]) + static_cast( wprof[1][0]), + static_cast( wprof[1][1]), + static_cast( wprof[1][2]) }, { - ( wprof[2][0] / Color::D50z), - ( wprof[2][1] / Color::D50z), - ( wprof[2][2] / Color::D50z) + static_cast( wprof[2][0] / Color::D50z), + static_cast( wprof[2][1] / Color::D50z), + static_cast( wprof[2][2] / Color::D50z) } }; @@ -3628,60 +3628,48 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int j = jstart, tj = 0; j < tW; j++, tj++) { - float r1, g1, b1, r2, g2, b2, L_1, L_2, Lfactor, a_1, b_1, x_, y_, z_, R, G, B ; - float y, fy, yy, fyy, x, z, fx, fz; - // rgb values before RGB curves - r1 = rtemp[ti * TS + tj] ; - g1 = gtemp[ti * TS + tj] ; - b1 = btemp[ti * TS + tj] ; + float r = rtemp[ti * TS + tj] ; + float g = gtemp[ti * TS + tj] ; + float b = btemp[ti * TS + tj] ; //convert to Lab to get a&b before RGB curves - x = toxyz[0][0] * r1 + toxyz[0][1] * g1 + toxyz[0][2] * b1; - y = toxyz[1][0] * r1 + toxyz[1][1] * g1 + toxyz[1][2] * b1; - z = toxyz[2][0] * r1 + toxyz[2][1] * g1 + toxyz[2][2] * b1; + float x = toxyz[0][0] * r + toxyz[0][1] * g + toxyz[0][2] * b; + float y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; + float z = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b; - fx = (x < 65535.0f ? Color::cachef[std::max(x, 0.f)] : 327.68f * std::cbrt(x / MAXVALF)); - fy = (y < 65535.0f ? Color::cachef[std::max(y, 0.f)] : 327.68f * std::cbrt(y / MAXVALF)); - fz = (z < 65535.0f ? Color::cachef[std::max(z, 0.f)] : 327.68f * std::cbrt(z / MAXVALF)); + float fx = x < 65535.0f ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF); + float fy = y < 65535.0f ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF); + float fz = z < 65535.0f ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF); - L_1 = (116.0f * fy - 5242.88f); //5242.88=16.0*327.68; - a_1 = (500.0f * (fx - fy) ); - b_1 = (200.0f * (fy - fz) ); + float a_1 = 500.0f * (fx - fy); + float b_1 = 200.0f * (fy - fz); // rgb values after RGB curves if (rCurve) { - r2 = rCurve[ rtemp[ti * TS + tj]]; - } else { - r2 = r1; + r = rCurve[r]; } if (gCurve) { - g2 = gCurve[ gtemp[ti * TS + tj]]; - } else { - g2 = g1; + g = gCurve[g]; } if (bCurve) { - b2 = bCurve[ btemp[ti * TS + tj]]; - } else { - b2 = b1; + b = bCurve[b]; } // Luminosity after // only Luminance in Lab - yy = toxyz[1][0] * r2 + toxyz[1][1] * g2 + toxyz[1][2] * b2; - fyy = (yy < 65535.0f ? Color::cachef[std::max(yy, 0.f)] : 327.68f * std::cbrt(yy / MAXVALF)); - L_2 = (116.0f * fyy - 5242.88f); + float newy = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; + float newfy = newy < 65535.0f ? Color::cachef[newy] : 327.68f * std::cbrt(newy / MAXVALF); + float L_2 = 116.0f * newfy - 5242.88f; //gamut control if(settings->rgbcurveslumamode_gamut) { - float RR, GG, BB; - float HH, Lpro, Chpro; - Lpro = L_2 / 327.68f; - Chpro = sqrt(SQR(a_1) + SQR(b_1)) / 327.68f; - HH = xatan2f(b_1, a_1); + float Lpro = L_2 / 327.68f; + float Chpro = sqrtf(SQR(a_1) + SQR(b_1)) / 327.68f; + float HH = xatan2f(b_1, a_1); // According to mathematical laws we can get the sin and cos of HH by simple operations - float2 sincosval; + float2 sincosval; if(Chpro == 0.0f) { sincosval.y = 1.0f; @@ -3695,30 +3683,18 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer bool neg = false; bool more_rgb = false; //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lpro, Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f, neg, more_rgb); + Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f, neg, more_rgb); #else //gamut control : Lab values are in gamut - Color::gamutLchonly(HH, Lpro, Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f); + Color::gamutLchonly(HH, sincosval, Lpro, Chpro, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip, highlight, 0.15f, 0.96f); #endif - - //Color::gamutLchonly(HH,Lpro,Chpro, RR, GG, BB, wip, highlight, 0.15f, 0.96f); - - - -// float2 sincosval = xsincosf(HH); - - L_2 = Lpro * 327.68f; - a_1 = 327.68f * Chpro * sincosval.y; - b_1 = 327.68f * Chpro * sincosval.x; - } //end of gamut control - - //calculate RGB with L_2 and old value of a and b - Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ; - Color::xyz2rgb(x_, y_, z_, R, G, B, wip); - - rtemp[ti * TS + tj] = R; - gtemp[ti * TS + tj] = G; - btemp[ti * TS + tj] = B; + //end of gamut control + } else { + float x_, y_, z_; + //calculate RGB with L_2 and old value of a and b + Color::Lab2XYZ(L_2, a_1, b_1, x_, y_, z_) ; + Color::xyz2rgb(x_, y_, z_, rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj], wip); + } } } } From 7a2dd888bb438fef1ba08b6c92911f08e1b2d0a4 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Fri, 26 Aug 2016 14:20:47 +0200 Subject: [PATCH 2/9] RGB Curves Luminosity mode, reduce number of atan2 calculations --- rtengine/color.cc | 7 ++++++- rtengine/improcfun.cc | 13 +++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/rtengine/color.cc b/rtengine/color.cc index 60d355b26..872f47522 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -2142,7 +2142,7 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr #ifdef _DEBUG neg = false, more_rgb = false; #endif - + float ChprovSave = Chprov1; do { inGamut = true; @@ -2165,6 +2165,11 @@ void Color::gamutLchonly (float HH, float2 sincosval, float &Lprov1, float &Chpr #ifdef _DEBUG neg = true; #endif + if (isnan(HH)) { + float atemp = ChprovSave * sincosval.y * 327.68; + float btemp = ChprovSave * sincosval.x * 327.68; + HH = xatan2f(btemp, atemp); + } if (Lprov1 < 0.1f) { Lprov1 = 0.1f; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 112ef9826..29ac45ca9 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -3637,9 +3637,9 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer float y = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; float z = toxyz[2][0] * r + toxyz[2][1] * g + toxyz[2][2] * b; - float fx = x < 65535.0f ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF); - float fy = y < 65535.0f ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF); - float fz = z < 65535.0f ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF); + float fx = x < MAXVALF ? Color::cachef[x] : 327.68f * std::cbrt(x / MAXVALF); + float fy = y < MAXVALF ? Color::cachef[y] : 327.68f * std::cbrt(y / MAXVALF); + float fz = z < MAXVALF ? Color::cachef[z] : 327.68f * std::cbrt(z / MAXVALF); float a_1 = 500.0f * (fx - fy); float b_1 = 200.0f * (fy - fz); @@ -3660,15 +3660,16 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // Luminosity after // only Luminance in Lab float newy = toxyz[1][0] * r + toxyz[1][1] * g + toxyz[1][2] * b; - float newfy = newy < 65535.0f ? Color::cachef[newy] : 327.68f * std::cbrt(newy / MAXVALF); + float newfy = newy < MAXVALF ? Color::cachef[newy] : 327.68f * std::cbrt(newy / MAXVALF); float L_2 = 116.0f * newfy - 5242.88f; //gamut control if(settings->rgbcurveslumamode_gamut) { float Lpro = L_2 / 327.68f; float Chpro = sqrtf(SQR(a_1) + SQR(b_1)) / 327.68f; - float HH = xatan2f(b_1, a_1); - // According to mathematical laws we can get the sin and cos of HH by simple operations + float HH = NAN; // we set HH to NAN, because then it will be calculated in Color::gamutLchonly only if needed +// float HH = xatan2f(b_1, a_1); + // According to mathematical laws we can get the sin and cos of HH by simple operations even if we don't calculate HH float2 sincosval; if(Chpro == 0.0f) { From 66054ca50dca6a3b868c62f8b896e34fd371131d Mon Sep 17 00:00:00 2001 From: heckflosse Date: Fri, 26 Aug 2016 16:38:14 +0200 Subject: [PATCH 3/9] RGB curves luminosity mode: Experimental patch to equalize the strength of R, G and B curve --- rtengine/improcfun.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 29ac45ca9..eb85e6577 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -2992,6 +2992,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer static_cast( wprof[2][2] / Color::D50z) } }; + float maxFactorToxyz = max(toxyz[1][0],toxyz[1][1],toxyz[1][2]); + float equalR = maxFactorToxyz / toxyz[1][0]; + float equalG = maxFactorToxyz / toxyz[1][1]; + float equalB = maxFactorToxyz / toxyz[1][2]; //inverse matrix user select double wip[3][3] = { @@ -3646,15 +3650,18 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer // rgb values after RGB curves if (rCurve) { - r = rCurve[r]; + float rNew = rCurve[r]; + r += (rNew - r) * equalR; } if (gCurve) { - g = gCurve[g]; + float gNew = gCurve[g]; + g += (gNew - g) * equalG; } if (bCurve) { - b = bCurve[b]; + float bNew = bCurve[b]; + b += (bNew - b) * equalB; } // Luminosity after From 46334c046242405409f1644d81829751a34945c6 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 28 Aug 2016 19:59:46 +0200 Subject: [PATCH 4/9] Disables StopWatch --- rtengine/improcfun.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index eb85e6577..c9bc41d71 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -40,7 +40,7 @@ #include "improccoordinator.h" #include "clutstore.h" #include "ciecam02.h" -#define BENCHMARK +//#define BENCHMARK #include "StopWatch.h" #include "../rtgui/ppversion.h" #include "../rtgui/guiutils.h" From 2ba7e296d01fff8534ce8538d69f426f174dc5fd Mon Sep 17 00:00:00 2001 From: Hombre Date: Mon, 29 Aug 2016 01:35:19 +0200 Subject: [PATCH 5/9] Bugfix: Options::readFromFile should not reset the options values. They are initialy set in the constructor then should only be updated by each call to this method. --- rtgui/options.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/rtgui/options.cc b/rtgui/options.cc index e723361be..ab887edfe 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -734,8 +734,6 @@ int Options::readFromFile (Glib::ustring fname) try { if (keyFile.load_from_file (fname)) { - setDefaults (); - // -------------------------------------------------------------------------------------------------------- if (keyFile.has_group ("General")) { @@ -1781,14 +1779,10 @@ int Options::readFromFile (Glib::ustring fname) if (options.rtSettings.verbose) { printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str()); } - - setDefaults (); } catch (...) { if (options.rtSettings.verbose) { printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str()); } - - setDefaults (); } return 1; From 6a19178e52a29ae80dd02a9bdfaf810807319fab Mon Sep 17 00:00:00 2001 From: heckflosse Date: Tue, 30 Aug 2016 01:53:27 +0200 Subject: [PATCH 6/9] Enable whole area of magnification windows for moving, fixes #3378 --- rtgui/cropwindow.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 6d39e0212..c4b555e8f 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -1029,8 +1029,7 @@ bool CropWindow::onArea (CursorArea a, int x, int y) } getObservedFrameArea (x1, y1, w, h); - return x > x1 - 6 && y > y1 - 6 && x < x1 + w - 1 + 6 && y < y1 + h - 1 + 6 && - !(x > x1 + 2 && y > y1 + 2 && x < x1 + w - 1 - 2 && y < y1 + h - 1 - 2); + return x >= x1 && x <= x1 + w && y >= y1 && y <= y1 + h; } return false; From 388d43ebcec62c9bdd9e8e0afec876a689d5ad89 Mon Sep 17 00:00:00 2001 From: Hombre Date: Wed, 31 Aug 2016 03:58:07 +0200 Subject: [PATCH 7/9] Adding new units for the RGB and HSV values in the Navigator tool (below Histogram). Click on one of thes two columns to cycle to a new unit independantly, between [0-1], [0-255], [%] (Hue stays in degree instead of percent). The current unit is saved in Options for new Editor tabs or between sessions. --- rtgui/navigator.cc | 113 +++++++++++++++++++++++++++++++++++++++++---- rtgui/navigator.h | 7 +++ rtgui/options.cc | 12 +++++ rtgui/options.h | 9 ++++ 4 files changed, 132 insertions(+), 9 deletions(-) diff --git a/rtgui/navigator.cc b/rtgui/navigator.cc index 4f7e638f2..eea574d24 100644 --- a/rtgui/navigator.cc +++ b/rtgui/navigator.cc @@ -26,9 +26,11 @@ #include "../rtengine/rt_math.h" #include "options.h" +extern Options options; + using namespace rtengine; -Navigator::Navigator () +Navigator::Navigator () : currentRGBUnit(options.navRGBUnit), currentHSVUnit(options.navHSVUnit) { set_label (M("MAIN_MSG_NAVIGATOR")); @@ -127,6 +129,7 @@ Navigator::Navigator () // RGB + Gtk::EventBox *evBox1 = Gtk::manage (new Gtk::EventBox()); Gtk::HBox* hbox1 = Gtk::manage (new Gtk::HBox ()); // container Gtk::Table* table1 = Gtk::manage (new Gtk::Table (3, 2)); @@ -139,11 +142,15 @@ Navigator::Navigator () table1->attach (*lB, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 4, 0); table1->attach (*B, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); - hbox1->pack_start (*table1, Gtk::PACK_EXPAND_WIDGET, 4); + evBox1->add (*table1); + evBox1->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Navigator::cycleUnitsRGB)); + + hbox1->pack_start (*evBox1, Gtk::PACK_EXPAND_WIDGET, 4); hbox1->pack_start (*Gtk::manage (new Gtk::VSeparator()), Gtk::PACK_SHRINK, 4); table0->attach (*hbox1, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); // HSV + Gtk::EventBox *evBox2 = Gtk::manage (new Gtk::EventBox()); Gtk::HBox* hbox2 = Gtk::manage (new Gtk::HBox ()); // container Gtk::Table* table2 = Gtk::manage (new Gtk::Table (3, 2)); @@ -156,7 +163,10 @@ Navigator::Navigator () table2->attach (*lV, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 4, 0); table2->attach (*V, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); - hbox2->pack_start (*table2, Gtk::PACK_EXPAND_WIDGET, 4); + evBox2->add (*table2); + evBox2->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Navigator::cycleUnitsHSV)); + + hbox2->pack_start (*evBox2, Gtk::PACK_EXPAND_WIDGET, 4); hbox2->pack_start (*Gtk::manage (new Gtk::VSeparator()), Gtk::PACK_SHRINK, 4); table0->attach (*hbox2, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); @@ -214,15 +224,45 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin } else { position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y)); - R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); - G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%")); - B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%")); + switch (currentRGBUnit) { + case (Options::NavigatorUnit::NU_0_1): + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f)); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f)); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f)); + break; + case (Options::NavigatorUnit::NU_0_255): + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r)); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g)); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b)); + break; + case (Options::NavigatorUnit::NU_PERCENT): + default: + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%")); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%")); + break; + } float h, s, v; Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v); - H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); - S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%")); - V->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%")); + switch (currentHSVUnit) { + case (Options::NavigatorUnit::NU_0_1): + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h)); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s)); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v)); + break; + case (Options::NavigatorUnit::NU_0_255): + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), h * 255)); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), s * 255)); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), v * 255)); + break; + case (Options::NavigatorUnit::NU_PERCENT): + default: + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%")); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%")); + break; + } float LAB_a, LAB_b, LAB_l; //rgb2lab (r, g, b, LAB_l, LAB_a, LAB_b); @@ -233,6 +273,61 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin } } +void Navigator::cycleUnitsRGB (GdkEventButton *event) { + uint16_t v = (uint16_t)currentRGBUnit; + ++v; + if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + v = 0; + } + options.navRGBUnit = currentRGBUnit = (Options::NavigatorUnit)v; + + switch (currentRGBUnit) { + case Options::NavigatorUnit::NU_0_1: + R->set_text ("[0-1]"); + G->set_text ("[0-1]"); + B->set_text ("[0-1]"); + break; + case Options::NavigatorUnit::NU_0_255: + R->set_text ("[0-255]"); + G->set_text ("[0-255]"); + B->set_text ("[0-255]"); + break; + case Options::NavigatorUnit::NU_PERCENT: + default: + R->set_text ("[%]"); + G->set_text ("[%]"); + B->set_text ("[%]"); + break; + } +} + +void Navigator::cycleUnitsHSV (GdkEventButton *event) { + uint16_t v = (uint16_t)currentHSVUnit; + ++v; + if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + v = 0; + } + options.navHSVUnit = currentHSVUnit = (Options::NavigatorUnit)v; + + switch (currentHSVUnit) { + case Options::NavigatorUnit::NU_0_1: + H->set_text ("[0-1]"); + S->set_text ("[0-1]"); + V->set_text ("[0-1]"); + break; + case Options::NavigatorUnit::NU_0_255: + H->set_text ("[0-255]"); + S->set_text ("[0-255]"); + V->set_text ("[0-255]"); + break; + case Options::NavigatorUnit::NU_PERCENT: + default: + H->set_text ("[\xc2\xb0]"); + S->set_text ("[%]"); + V->set_text ("[%]"); + break; + } +} void Navigator::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b) { diff --git a/rtgui/navigator.h b/rtgui/navigator.h index 3abf34a2f..e0b79d8dd 100644 --- a/rtgui/navigator.h +++ b/rtgui/navigator.h @@ -22,6 +22,7 @@ #include #include "previewwindow.h" #include "pointermotionlistener.h" +#include "options.h" #include "../rtengine/iccstore.h" class Navigator : public Gtk::Frame, public PointerMotionListener @@ -29,6 +30,12 @@ class Navigator : public Gtk::Frame, public PointerMotionListener typedef const double (*TMatrix)[3]; +private: + Options::NavigatorUnit currentRGBUnit; + Options::NavigatorUnit currentHSVUnit; + void cycleUnitsRGB (GdkEventButton *event); + void cycleUnitsHSV (GdkEventButton *event); + protected: Gtk::Label* position; Gtk::Label *R, *G, *B; diff --git a/rtgui/options.cc b/rtgui/options.cc index e723361be..cec5eaef8 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -353,6 +353,8 @@ void Options::setDefaults () fbShowExpComp = false; fbShowHidden = false; fbArrangement = 2; // was 0 + navRGBUnit = NavigatorUnit::NU_PERCENT; + navHSVUnit = NavigatorUnit::NU_PERCENT; multiUser = true; profilePath = "profiles"; loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails @@ -1407,6 +1409,14 @@ int Options::readFromFile (Glib::ustring fname) histogramFullMode = keyFile.get_boolean ("GUI", "HistogramFullMode"); } + if (keyFile.has_key ("GUI", "NavigatorRGBUnit")) { + navRGBUnit = (NavigatorUnit)keyFile.get_integer ("GUI", "NavigatorRGBUnit"); + } + + if (keyFile.has_key ("GUI", "NavigatorHSVUnit")) { + navHSVUnit = (NavigatorUnit)keyFile.get_integer ("GUI", "NavigatorHSVUnit"); + } + if (keyFile.has_key ("GUI", "ShowFilmStripToolBar")) { showFilmStripToolBar = keyFile.get_boolean ("GUI", "ShowFilmStripToolBar"); } @@ -2010,6 +2020,8 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition); keyFile.set_boolean ("GUI", "HistogramBar", histogramBar); keyFile.set_boolean ("GUI", "HistogramFullMode", histogramFullMode); + keyFile.set_integer ("GUI", "NavigatorRGBUnit", (int)navRGBUnit); + keyFile.set_integer ("GUI", "NavigatorHSVUnit", (int)navHSVUnit); keyFile.set_boolean ("GUI", "ShowFilmStripToolBar", showFilmStripToolBar); keyFile.set_boolean ("GUI", "FileBrowserToolbarSingleRow", FileBrowserToolbarSingleRow); keyFile.set_boolean ("GUI", "HideTPVScrollbar", hideTPVScrollbar); diff --git a/rtgui/options.h b/rtgui/options.h index 4da827f36..8d374d4cd 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -86,6 +86,13 @@ private: const Glib::ustring& entryName, Glib::ustring& destination); public: + + enum class NavigatorUnit { + NU_PERCENT, + NU_0_255, + NU_0_1, + NU__COUNT, + }; bool savesParamsAtExit; SaveFormat saveFormat, saveFormatBatch; Glib::ustring savePathTemplate; @@ -133,6 +140,8 @@ public: bool fbShowExpComp; bool fbShowHidden; int fbArrangement; + NavigatorUnit navRGBUnit; + NavigatorUnit navHSVUnit; bool multiUser; static Glib::ustring rtdir; Glib::ustring version; From f3d46f4c3768d04931651cb9989feaf3070279cd Mon Sep 17 00:00:00 2001 From: Hombre Date: Wed, 31 Aug 2016 13:40:02 +0200 Subject: [PATCH 8/9] Minor code adjustment --- rtgui/navigator.cc | 28 ++++++++++++++-------------- rtgui/options.cc | 4 ++-- rtgui/options.h | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/rtgui/navigator.cc b/rtgui/navigator.cc index eea574d24..049b4ec7e 100644 --- a/rtgui/navigator.cc +++ b/rtgui/navigator.cc @@ -225,17 +225,17 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y)); switch (currentRGBUnit) { - case (Options::NavigatorUnit::NU_0_1): + case (Options::NavigatorUnit::R0_1): R->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f)); G->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f)); B->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f)); break; - case (Options::NavigatorUnit::NU_0_255): + case (Options::NavigatorUnit::R0_255): R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r)); G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g)); B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b)); break; - case (Options::NavigatorUnit::NU_PERCENT): + case (Options::NavigatorUnit::PERCENT): default: R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%")); @@ -246,17 +246,17 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin float h, s, v; Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v); switch (currentHSVUnit) { - case (Options::NavigatorUnit::NU_0_1): + case (Options::NavigatorUnit::R0_1): H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h)); S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s)); V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v)); break; - case (Options::NavigatorUnit::NU_0_255): + case (Options::NavigatorUnit::R0_255): H->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), h * 255)); S->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), s * 255)); V->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), v * 255)); break; - case (Options::NavigatorUnit::NU_PERCENT): + case (Options::NavigatorUnit::PERCENT): default: H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%")); @@ -276,23 +276,23 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin void Navigator::cycleUnitsRGB (GdkEventButton *event) { uint16_t v = (uint16_t)currentRGBUnit; ++v; - if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + if (v == (uint16_t)Options::NavigatorUnit::_COUNT) { v = 0; } options.navRGBUnit = currentRGBUnit = (Options::NavigatorUnit)v; switch (currentRGBUnit) { - case Options::NavigatorUnit::NU_0_1: + case Options::NavigatorUnit::R0_1: R->set_text ("[0-1]"); G->set_text ("[0-1]"); B->set_text ("[0-1]"); break; - case Options::NavigatorUnit::NU_0_255: + case Options::NavigatorUnit::R0_255: R->set_text ("[0-255]"); G->set_text ("[0-255]"); B->set_text ("[0-255]"); break; - case Options::NavigatorUnit::NU_PERCENT: + case Options::NavigatorUnit::PERCENT: default: R->set_text ("[%]"); G->set_text ("[%]"); @@ -304,23 +304,23 @@ void Navigator::cycleUnitsRGB (GdkEventButton *event) { void Navigator::cycleUnitsHSV (GdkEventButton *event) { uint16_t v = (uint16_t)currentHSVUnit; ++v; - if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + if (v == (uint16_t)Options::NavigatorUnit::_COUNT) { v = 0; } options.navHSVUnit = currentHSVUnit = (Options::NavigatorUnit)v; switch (currentHSVUnit) { - case Options::NavigatorUnit::NU_0_1: + case Options::NavigatorUnit::R0_1: H->set_text ("[0-1]"); S->set_text ("[0-1]"); V->set_text ("[0-1]"); break; - case Options::NavigatorUnit::NU_0_255: + case Options::NavigatorUnit::R0_255: H->set_text ("[0-255]"); S->set_text ("[0-255]"); V->set_text ("[0-255]"); break; - case Options::NavigatorUnit::NU_PERCENT: + case Options::NavigatorUnit::PERCENT: default: H->set_text ("[\xc2\xb0]"); S->set_text ("[%]"); diff --git a/rtgui/options.cc b/rtgui/options.cc index cec5eaef8..e7ac7f0df 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -353,8 +353,8 @@ void Options::setDefaults () fbShowExpComp = false; fbShowHidden = false; fbArrangement = 2; // was 0 - navRGBUnit = NavigatorUnit::NU_PERCENT; - navHSVUnit = NavigatorUnit::NU_PERCENT; + navRGBUnit = NavigatorUnit::PERCENT; + navHSVUnit = NavigatorUnit::PERCENT; multiUser = true; profilePath = "profiles"; loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails diff --git a/rtgui/options.h b/rtgui/options.h index 8d374d4cd..c25708674 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -88,10 +88,10 @@ private: public: enum class NavigatorUnit { - NU_PERCENT, - NU_0_255, - NU_0_1, - NU__COUNT, + PERCENT, + R0_255, + R0_1, + _COUNT }; bool savesParamsAtExit; SaveFormat saveFormat, saveFormatBatch; From db6b43e3c0c6d18cae33d48e80935dc99a620be2 Mon Sep 17 00:00:00 2001 From: Beep6581 Date: Wed, 31 Aug 2016 14:12:31 +0200 Subject: [PATCH 9/9] Updated links Added link to RawTherapee forum at pixls.us Removed dead link to Michael's code documentation. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e90807b73..93dbfec59 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ Of course, professionals may use RawTherapee too while enjoying complete freedom Website: http://rawtherapee.com/ +Forum: +https://discuss.pixls.us/c/software/rawtherapee + Features: http://rawpedia.rawtherapee.com/Features @@ -25,9 +28,6 @@ http://rawtherapee.com/downloads Download source code tarballs: http://rawtherapee.com/shared/source/ -Source code documentation: -http://michaelezra.com/projects/rt/documentation/ - Git handbook: http://git-scm.com/book/en/