Add CIELAB lightness to waveform
This commit is contained in:
@@ -2253,11 +2253,12 @@ void EditorPanel::histogramChanged(
|
||||
int waveformWidth,
|
||||
const int waveformRed[][256],
|
||||
const int waveformGreen[][256],
|
||||
const int waveformBlue[][256]
|
||||
const int waveformBlue[][256],
|
||||
const int waveformLuma[][256]
|
||||
)
|
||||
{
|
||||
if (histogramPanel) {
|
||||
histogramPanel->histogramChanged(histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw, vectorscopeScale, vectorscope, waveformScale, waveformWidth, waveformRed, waveformGreen, waveformBlue);
|
||||
histogramPanel->histogramChanged(histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw, vectorscopeScale, vectorscope, waveformScale, waveformWidth, waveformRed, waveformGreen, waveformBlue, waveformLuma);
|
||||
}
|
||||
|
||||
tpc->updateCurveBackgroundHistogram(histToneCurve, histLCurve, histCCurve, histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI);
|
||||
|
||||
@@ -134,7 +134,8 @@ public:
|
||||
int waveformWidth,
|
||||
const int waveformRed[][256],
|
||||
const int waveformGreen[][256],
|
||||
const int waveformBlue[][256]
|
||||
const int waveformBlue[][256],
|
||||
const int waveformLuma[][256]
|
||||
) override;
|
||||
void setObservable(rtengine::HistogramObservable* observable) override;
|
||||
bool updateHistogram(void) override;
|
||||
|
||||
@@ -379,7 +379,7 @@ void HistogramPanel::type_changed()
|
||||
showRed->set_sensitive();
|
||||
showGreen->set_sensitive();
|
||||
showBlue->set_sensitive();
|
||||
showValue->set_sensitive(false);
|
||||
showValue->set_sensitive();
|
||||
showChro->set_sensitive(false);
|
||||
showRAW->set_sensitive(false);
|
||||
showMode->set_sensitive(false);
|
||||
@@ -663,7 +663,7 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin
|
||||
drawBar(cc, b, 255.0, winw, winh, s);
|
||||
}
|
||||
|
||||
if((needLuma || needChroma) && options.histogramScopeType == 0) {
|
||||
if((needLuma || needChroma) && options.histogramScopeType <= 1) {
|
||||
float Lab_L, Lab_a, Lab_b;
|
||||
rtengine::Color::rgb2lab01(profile, profileW, r / 255.f, g / 255.f, b / 255.f, Lab_L, Lab_a, Lab_b, options.rtSettings.HistogramWorking);
|
||||
|
||||
@@ -673,7 +673,7 @@ void HistogramRGBArea::updateBackBuffer (int r, int g, int b, const Glib::ustrin
|
||||
drawBar(cc, Lab_L, 100.0, winw, winh, s);
|
||||
}
|
||||
|
||||
if (needChroma) {
|
||||
if (needChroma && options.histogramScopeType == 0) {
|
||||
// Chroma
|
||||
double chromaval = sqrt(Lab_a * Lab_a + Lab_b * Lab_b) / 1.8;
|
||||
cc->set_source_rgb(0.9, 0.9, 0.0);
|
||||
@@ -960,7 +960,8 @@ void HistogramArea::update(
|
||||
int waveformWidth,
|
||||
const int waveformRed[][256],
|
||||
const int waveformGreen[][256],
|
||||
const int waveformBlue[][256]
|
||||
const int waveformBlue[][256],
|
||||
const int waveformLuma[][256]
|
||||
)
|
||||
{
|
||||
if (histRed) {
|
||||
@@ -980,13 +981,16 @@ void HistogramArea::update(
|
||||
rwave.reset(new int[waveformWidth][256]);
|
||||
gwave.reset(new int[waveformWidth][256]);
|
||||
bwave.reset(new int[waveformWidth][256]);
|
||||
lwave.reset(new int[waveformWidth][256]);
|
||||
}
|
||||
int (* const rw)[256] = rwave.get();
|
||||
int (* const gw)[256] = gwave.get();
|
||||
int (* const bw)[256] = bwave.get();
|
||||
int (* const lw)[256] = lwave.get();
|
||||
memcpy(rw, waveformRed, 256 * waveformWidth * sizeof(rw[0][0]));
|
||||
memcpy(gw, waveformGreen, 256 * waveformWidth * sizeof(gw[0][0]));
|
||||
memcpy(bw, waveformBlue, 256 * waveformWidth * sizeof(bw[0][0]));
|
||||
memcpy(lw, waveformLuma, 256 * waveformWidth * sizeof(lw[0][0]));
|
||||
wave_buffer_dirty = true;
|
||||
} else if (scopeType >= 2) {
|
||||
vectorscope_scale = vectorscopeScale;
|
||||
@@ -1392,9 +1396,11 @@ void HistogramArea::drawWaveform(Cairo::RefPtr<Cairo::Context> &cr, int w, int h
|
||||
|
||||
if (wave_buffer_dirty) {
|
||||
wave_buffer.reset(new unsigned char[256 * cairo_stride]);
|
||||
wave_buffer_luma.reset(new unsigned char[256 * cairo_stride]);
|
||||
|
||||
// Clear waveform.
|
||||
memset(wave_buffer.get(), 0, 256 * cairo_stride);
|
||||
memset(wave_buffer_luma.get(), 0, 256 * cairo_stride);
|
||||
|
||||
// TODO: Optimize.
|
||||
for (int col = 0; col < waveform_width; col++) {
|
||||
@@ -1413,6 +1419,16 @@ void HistogramArea::drawWaveform(Cairo::RefPtr<Cairo::Context> &cr, int w, int h
|
||||
}
|
||||
}
|
||||
|
||||
if (needLuma) {
|
||||
for (int col = 0; col < waveform_width; col++) {
|
||||
for (int val = 0; val < 256; val++) {
|
||||
const unsigned char l = min<float>(scale * lwave[col][val], 0xff);
|
||||
*(uint32_t*)&(wave_buffer_luma[(255 - val) * cairo_stride + col * 4]) =
|
||||
l | (l << 8) | (l << 16) | (l << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wave_buffer_dirty = false;
|
||||
}
|
||||
|
||||
@@ -1424,6 +1440,13 @@ void HistogramArea::drawWaveform(Cairo::RefPtr<Cairo::Context> &cr, int w, int h
|
||||
cr->set_source(surface, 0, 0);
|
||||
cr->set_operator(Cairo::OPERATOR_OVER);
|
||||
cr->paint();
|
||||
if (needLuma) {
|
||||
surface = Cairo::ImageSurface::create(
|
||||
wave_buffer_luma.get(), Cairo::FORMAT_ARGB32, waveform_width, 256, cairo_stride);
|
||||
cr->set_source(surface, 0, 0);
|
||||
cr->set_operator(Cairo::OPERATOR_OVER);
|
||||
cr->paint();
|
||||
}
|
||||
surface->finish();
|
||||
cr->set_matrix(orig_matrix);
|
||||
}
|
||||
|
||||
@@ -167,8 +167,9 @@ protected:
|
||||
bool vect_buffer_dirty;
|
||||
int waveform_scale;
|
||||
int waveform_width;
|
||||
std::unique_ptr<int[][256]> rwave, gwave, bwave;
|
||||
std::unique_ptr<int[][256]> rwave, gwave, bwave, lwave;
|
||||
std::unique_ptr<unsigned char[]> wave_buffer;
|
||||
std::unique_ptr<unsigned char[]> wave_buffer_luma;
|
||||
bool wave_buffer_dirty;
|
||||
|
||||
bool valid;
|
||||
@@ -206,7 +207,8 @@ public:
|
||||
int waveformWidth,
|
||||
const int waveformRed[][256],
|
||||
const int waveformGreen[][256],
|
||||
const int waveformBlue[][256]
|
||||
const int waveformBlue[][256],
|
||||
const int waveformLuma[][256]
|
||||
);
|
||||
void updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, int mode, int type);
|
||||
void on_realize() override;
|
||||
@@ -309,10 +311,11 @@ public:
|
||||
int waveformWidth,
|
||||
const int waveformRed[][256],
|
||||
const int waveformGreen[][256],
|
||||
const int waveformBlue[][256]
|
||||
const int waveformBlue[][256],
|
||||
const int waveformLuma[][256]
|
||||
)
|
||||
{
|
||||
histogramArea->update(histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw, vectorscopeScale, vectorscope, waveformScale, waveformWidth, waveformRed, waveformGreen, waveformBlue);
|
||||
histogramArea->update(histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw, vectorscopeScale, vectorscope, waveformScale, waveformWidth, waveformRed, waveformGreen, waveformBlue, waveformLuma);
|
||||
}
|
||||
// pointermotionlistener interface
|
||||
void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw = false) override;
|
||||
|
||||
Reference in New Issue
Block a user