Fix incorrect sampled L*a*b* values

Use LCMS to convert values back into L*a*b*. The pipette buffer has the
output or working profile applied with LCMS. Performing the inverse
operation fixes the incorrect values shown in the navigator, histogram
indicator bars, and lockable color pickers.
This commit is contained in:
Lawrence Lee
2023-05-28 18:15:27 -07:00
parent 6a11c59b79
commit 8accebe416
10 changed files with 144 additions and 36 deletions

View File

@@ -21,18 +21,26 @@
#include "previewwindow.h"
#include "toolpanel.h"
#include "../rtengine/color.h"
#include "../rtengine/improcfun.h"
#include "../rtengine/rt_math.h"
#include "options.h"
using namespace rtengine;
namespace
{
const rtengine::procparams::ColorManagementParams DEFAULT_CMP;
}
Navigator::Navigator() :
pointer_moved_delayed_call(50, 100),
currentRGBUnit(options.navRGBUnit),
currentHSVUnit(options.navHSVUnit)
{
pointer_moved_delayed_call.setFunction(
[this](bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b, bool isRaw)
[this](bool validPos, const rtengine::procparams::ColorManagementParams *cmp, int x, int y, int r, int g, int b, bool isRaw)
{
if (!validPos) {
setInvalid (x, y);
@@ -61,7 +69,16 @@ Navigator::Navigator() :
S->set_text (s2);
V->set_text (s3);
Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, LAB_l, LAB_a, LAB_b, options.rtSettings.HistogramWorking); // TODO: Really sure this function works?
ImProcFunctions::rgb2lab(
static_cast<std::uint8_t>(r),
static_cast<std::uint8_t>(g),
static_cast<std::uint8_t>(b),
LAB_l, LAB_a, LAB_b,
cmp != nullptr ? *cmp : DEFAULT_CMP,
true);
LAB_l /= 327.68f;
LAB_a /= 327.68f;
LAB_b /= 327.68f;
getLABText (LAB_l, LAB_a, LAB_b, s1, s2, s3);
LAB_L->set_text (s1);
LAB_A->set_text (s2);
@@ -328,9 +345,9 @@ void Navigator::getLABText (float l, float a, float b, Glib::ustring &sL, Glib::
}
// if !validPos then x/y contain the full image size
void Navigator::pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw)
void Navigator::pointerMoved (bool validPos, const rtengine::procparams::ColorManagementParams &cmp, int x, int y, int r, int g, int b, bool isRaw)
{
pointer_moved_delayed_call(validPos, profile, profileW, x, y, r, g, b, isRaw);
pointer_moved_delayed_call(validPos, &cmp, x, y, r, g, b, isRaw);
}
void Navigator::cycleUnitsRGB (GdkEventButton *event) {