Preview modes: R,B,G channels and Luminosity (issue 1167)

This commit is contained in:
michael
2011-12-24 12:04:22 -05:00
parent 4caeb2b0fb
commit e1d0a0025d
9 changed files with 262 additions and 21 deletions

View File

@@ -475,6 +475,11 @@ MAIN_TOOLTIP_HIDEFP;Show/hide the bottom panel (directory and file browser) <b>F
MAIN_TOOLTIP_HIDEHP;Show/hide the left panel (including the history) <b>l</b> MAIN_TOOLTIP_HIDEHP;Show/hide the left panel (including the history) <b>l</b>
MAIN_TOOLTIP_INDCLIPPEDH;Clipped highlight indication (Key <) MAIN_TOOLTIP_INDCLIPPEDH;Clipped highlight indication (Key <)
MAIN_TOOLTIP_INDCLIPPEDS;Clipped shadow indication (Key >) MAIN_TOOLTIP_INDCLIPPEDS;Clipped shadow indication (Key >)
MAIN_TOOLTIP_PREVIEWB;Preview <b>Blue channel</b>
MAIN_TOOLTIP_PREVIEWFOCUSMASK;Preview <b>Focus Mask</b>
MAIN_TOOLTIP_PREVIEWG;Preview <b>Green channel</b>
MAIN_TOOLTIP_PREVIEWR;Preview <b>Red channel</b>
MAIN_TOOLTIP_PREVIEWL;Preview <b>Luminosity</b>\n0.299*R + 0.587*G + 0.114*B
MAIN_TOOLTIP_PREFERENCES;Set preferences MAIN_TOOLTIP_PREFERENCES;Set preferences
MAIN_TOOLTIP_QINFO;Quick info on the image <b>I</b> MAIN_TOOLTIP_QINFO;Quick info on the image <b>I</b>
MAIN_TOOLTIP_SAVEAS;Save image to a selected folder MAIN_TOOLTIP_SAVEAS;Save image to a selected folder
@@ -483,6 +488,7 @@ MAIN_TOOLTIP_SHOWHIDELP1;Show/hide the left panel <b>l</b>
MAIN_TOOLTIP_SHOWHIDERP1;Show/hide the right panel <b>Alt-l</b> MAIN_TOOLTIP_SHOWHIDERP1;Show/hide the right panel <b>Alt-l</b>
MAIN_TOOLTIP_SHOWHIDETP1;Show/hide the top panel <b>Shift-l</b> MAIN_TOOLTIP_SHOWHIDETP1;Show/hide the top panel <b>Shift-l</b>
MAIN_TOOLTIP_TOGGLE;Toggle <b>before</b>/<b>after</b> view <b>B</b> MAIN_TOOLTIP_TOGGLE;Toggle <b>before</b>/<b>after</b> view <b>B</b>
MAIN_TOOLTIP_THRESHOLD;Threshold
NAVIGATOR_B_NA;B = n/a NAVIGATOR_B_NA;B = n/a
NAVIGATOR_B_VALUE;B = %1 NAVIGATOR_B_VALUE;B = %1
NAVIGATOR_G_NA;G = n/a NAVIGATOR_G_NA;G = n/a

View File

@@ -1,6 +1,6 @@
set (BASESOURCEFILES set (BASESOURCEFILES
editwindow.cc batchtoolpanelcoord.cc paramsedited.cc cropwindow.cc previewhandler.cc previewwindow.cc navigator.cc indclippedpanel.cc filterpanel.cc editwindow.cc batchtoolpanelcoord.cc paramsedited.cc cropwindow.cc previewhandler.cc previewwindow.cc navigator.cc indclippedpanel.cc previewmodepanel.cc filterpanel.cc
cursormanager.cc rtwindow.cc renamedlg.cc recentbrowser.cc placesbrowser.cc filepanel.cc editorpanel.cc batchqueuepanel.cc cursormanager.cc rtwindow.cc renamedlg.cc recentbrowser.cc placesbrowser.cc filepanel.cc editorpanel.cc batchqueuepanel.cc
ilabel.cc thumbbrowserbase.cc adjuster.cc filebrowserentry.cc filebrowser.cc filethumbnailbuttonset.cc ilabel.cc thumbbrowserbase.cc adjuster.cc filebrowserentry.cc filebrowser.cc filethumbnailbuttonset.cc
cachemanager.cc cacheimagedata.cc shcselector.cc perspective.cc cachemanager.cc cacheimagedata.cc shcselector.cc perspective.cc

View File

@@ -677,6 +677,16 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
//t3.set (); //t3.set ();
bool showcs = iarea->indClippedPanel->showClippedShadows(); bool showcs = iarea->indClippedPanel->showClippedShadows();
bool showch = iarea->indClippedPanel->showClippedHighlights(); bool showch = iarea->indClippedPanel->showClippedHighlights();
bool showR = iarea->previewModePanel->showR();
bool showG = iarea->previewModePanel->showG();
bool showB = iarea->previewModePanel->showB();
bool showL = iarea->previewModePanel->showL();
bool showFocusMask = iarea->previewModePanel->showFocusMask();
// additional flags to control clipping indicators for individual channels and across all channels
bool showclippedAll = (!showR && !showG && !showB && !showL);
bool showclippedR = showR || showL || showclippedAll;
bool showclippedG = showG || showL || showclippedAll;
bool showclippedB = showB || showL || showclippedAll;
// If ALT was pressed, auto-enable highlight and shadow // If ALT was pressed, auto-enable highlight and shadow
// TODO: Add linux/MacOS specific functions for alternative // TODO: Add linux/MacOS specific functions for alternative
@@ -686,7 +696,7 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
} }
#endif #endif
if (showcs || showch) { if (showcs || showch || showR || showG || showB || showL /*|| showFocusMask*/) {
Glib::RefPtr<Gdk::Pixbuf> tmp = cropHandler.cropPixbuf->copy (); Glib::RefPtr<Gdk::Pixbuf> tmp = cropHandler.cropPixbuf->copy ();
guint8* pix = tmp->get_pixels(); guint8* pix = tmp->get_pixels();
guint8* pixWrkSpace = cropHandler.cropPixbuftrue->get_pixels(); guint8* pixWrkSpace = cropHandler.cropPixbuftrue->get_pixels();
@@ -704,36 +714,59 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
guint8* curr = pix + i*pixRowStride; guint8* curr = pix + i*pixRowStride;
guint8* currWS = pixWrkSpace + i*pixWSRowStride; guint8* currWS = pixWrkSpace + i*pixWSRowStride;
int delta; bool changed; int delta; bool changedHL; bool changedSH;
for (int j=0; j<tmp->get_width(); j++) { for (int j=0; j<tmp->get_width(); j++) {
// we must compare clippings in working space, since the cropPixbuf is in sRGB, with mon profile // we must compare clippings in working space, since the cropPixbuf is in sRGB, with mon profile
changedHL=false;
changedSH=false;
if (showch) { if (showch) {
delta=0; changed=false; delta=0; changedHL=false;
if (currWS[0]>=options.highlightThreshold) { delta += 255-currWS[0]; changed=true; } if (currWS[0]>=options.highlightThreshold && showclippedR) { delta += 255-currWS[0]; changedHL=true; }
if (currWS[1]>=options.highlightThreshold) { delta += 255-currWS[1]; changed=true; } if (currWS[1]>=options.highlightThreshold && showclippedG) { delta += 255-currWS[1]; changedHL=true; }
if (currWS[2]>=options.highlightThreshold) { delta += 255-currWS[2]; changed=true; } if (currWS[2]>=options.highlightThreshold && showclippedB) { delta += 255-currWS[2]; changedHL=true; }
if (changed) { if (changedHL) {
delta *= HighlightFac; delta *= HighlightFac;
curr[0]=curr[1]=curr[2]=delta; if (showclippedAll) curr[0]=curr[1]=curr[2]=delta; // indicate clipped highlights in gray
else {curr[0]=255; curr[1]=curr[2]=delta;} // indicate clipped highlights in red
} }
} }
if (showcs) { if (showcs) {
delta=0; changed=false; delta=0; changedSH=false;
if (currWS[0]<=options.shadowThreshold) { delta += currWS[0]; changed=true; } if (currWS[0]<=options.shadowThreshold && showclippedR) { delta += currWS[0]; changedSH=true; }
if (currWS[1]<=options.shadowThreshold) { delta += currWS[1]; changed=true; } if (currWS[1]<=options.shadowThreshold && showclippedG) { delta += currWS[1]; changedSH=true; }
if (currWS[2]<=options.shadowThreshold) { delta += currWS[2]; changed=true; } if (currWS[2]<=options.shadowThreshold && showclippedB) { delta += currWS[2]; changedSH=true; }
if (changedSH) {
if (showclippedAll) {
delta = 255 - (delta * ShawdowFac);
curr[0]=curr[1]=curr[2]=delta; // indicate clipped shadows in gray
}
else {
delta *= ShawdowFac;
curr[2]=255; curr[0]=curr[1]=delta; // indicate clipped shadows in blue
}
}
} //if (showcs)
if (changed) { // modulate the preview of channels & L;
delta = 255 - (delta * ShawdowFac); if (!changedHL && !changedSH){ //This condition allows clipping indicators for RGB channels to remain in color
curr[0]=curr[1]=curr[2]=delta; if (showR) curr[1]=curr[2]=curr[0]; //Red channel in grayscale
if (showG) curr[0]=curr[2]=curr[1]; //Green channel in grayscale
if (showB) curr[0]=curr[1]=curr[2]; //Blue channel in grayscale
if (showL) { //Luminosity
// see http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness for more info
//int L = (int)(0.212671*curr[0]+0.715160*curr[1]+0.072169*curr[2]);
int L = (int)(0.299*curr[0]+0.587*curr[1]+0.114*curr[2]); //Lightness - this matches Luminance mode in Photoshop CS5
curr[0]=curr[1]=curr[2]=L;
} }
} }
//if (showFocusMask){}; TODO add display of focus mask here
/* /*
if (showch && (currWS[0]>=options.highlightThreshold || currWS[1]>=options.highlightThreshold || currWS[2]>=options.highlightThreshold)) if (showch && (currWS[0]>=options.highlightThreshold || currWS[1]>=options.highlightThreshold || currWS[2]>=options.highlightThreshold))

View File

@@ -126,6 +126,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
Gtk::VSeparator* vsepcl = Gtk::manage (new Gtk::VSeparator ()); Gtk::VSeparator* vsepcl = Gtk::manage (new Gtk::VSeparator ());
Gtk::VSeparator* vsepz2 = Gtk::manage (new Gtk::VSeparator ()); Gtk::VSeparator* vsepz2 = Gtk::manage (new Gtk::VSeparator ());
Gtk::VSeparator* vsepz3 = Gtk::manage (new Gtk::VSeparator ()); Gtk::VSeparator* vsepz3 = Gtk::manage (new Gtk::VSeparator ());
Gtk::VSeparator* vsepz4 = Gtk::manage (new Gtk::VSeparator ());
iarea = new ImageAreaPanel (); iarea = new ImageAreaPanel ();
@@ -144,6 +145,8 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
toolBarPanel->pack_end (*vsepcl, Gtk::PACK_SHRINK, 2); toolBarPanel->pack_end (*vsepcl, Gtk::PACK_SHRINK, 2);
toolBarPanel->pack_end (*iarea->imageArea->indClippedPanel, Gtk::PACK_SHRINK, 0); toolBarPanel->pack_end (*iarea->imageArea->indClippedPanel, Gtk::PACK_SHRINK, 0);
toolBarPanel->pack_end (*vsepz, Gtk::PACK_SHRINK, 2); toolBarPanel->pack_end (*vsepz, Gtk::PACK_SHRINK, 2);
toolBarPanel->pack_end (*iarea->imageArea->previewModePanel, Gtk::PACK_SHRINK, 0);
toolBarPanel->pack_end (*vsepz4, Gtk::PACK_SHRINK, 2);
afterBox = Gtk::manage (new Gtk::VBox ()); afterBox = Gtk::manage (new Gtk::VBox ());
afterBox->pack_start (*iarea); afterBox->pack_start (*iarea);
@@ -849,7 +852,7 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) {
case GDK_greater: case GDK_greater:
iarea->imageArea->indClippedPanel->toggleClipped(false); iarea->imageArea->indClippedPanel->toggleClipped(false);
return true; return true;
//TODO add shortcuts for previewModePanel buttons
case GDK_F5: case GDK_F5:
openThm->openDefaultViewer(event->state & GDK_SHIFT_MASK ? 2 : 1); openThm->openDefaultViewer(event->state & GDK_SHIFT_MASK ? 2 : 1);
return true; return true;

View File

@@ -42,6 +42,7 @@ ImageArea::ImageArea (ImageAreaPanel* p) : parent(p) {
zoomPanel = Gtk::manage (new ZoomPanel (this)); zoomPanel = Gtk::manage (new ZoomPanel (this));
indClippedPanel = Gtk::manage (new IndicateClippedPanel (this)); indClippedPanel = Gtk::manage (new IndicateClippedPanel (this));
previewModePanel = Gtk::manage (new PreviewModePanel (this));
signal_style_changed().connect( sigc::mem_fun(*this, &ImageArea::styleChanged) ); signal_style_changed().connect( sigc::mem_fun(*this, &ImageArea::styleChanged) );
signal_size_allocate().connect( sigc::mem_fun(*this, &ImageArea::on_resized) ); signal_size_allocate().connect( sigc::mem_fun(*this, &ImageArea::on_resized) );

View File

@@ -29,6 +29,7 @@
#include "cropwindow.h" #include "cropwindow.h"
#include "zoompanel.h" #include "zoompanel.h"
#include "indclippedpanel.h" #include "indclippedpanel.h"
#include "previewmodepanel.h"
class ImageAreaPanel; class ImageAreaPanel;
class ImageArea : public Gtk::DrawingArea, public CropWindowListener { class ImageArea : public Gtk::DrawingArea, public CropWindowListener {
@@ -64,6 +65,7 @@ class ImageArea : public Gtk::DrawingArea, public CropWindowListener {
CropWindow* mainCropWindow; CropWindow* mainCropWindow;
ZoomPanel* zoomPanel; ZoomPanel* zoomPanel;
IndicateClippedPanel* indClippedPanel; IndicateClippedPanel* indClippedPanel;
PreviewModePanel* previewModePanel;
ImageArea (ImageAreaPanel* p); ImageArea (ImageAreaPanel* p);
~ImageArea (); ~ImageArea ();

View File

@@ -28,14 +28,14 @@ IndicateClippedPanel::IndicateClippedPanel (ImageArea* ia) : imageArea(ia) {
indclippedh = Gtk::manage (new Gtk::ToggleButton ()); indclippedh = Gtk::manage (new Gtk::ToggleButton ());
indclippedh->set_relief(Gtk::RELIEF_NONE); indclippedh->set_relief(Gtk::RELIEF_NONE);
indclippedh->add (*Gtk::manage (new RTImage ("warnhl.png"))); indclippedh->add (*Gtk::manage (new RTImage ("warnhl.png")));
tt = M("MAIN_TOOLTIP_INDCLIPPEDH"); tt = Glib::ustring::compose("%1\n%2 = %3",M("MAIN_TOOLTIP_INDCLIPPEDH"),M("MAIN_TOOLTIP_THRESHOLD"),options.highlightThreshold);
if (tt.find("&lt;") == Glib::ustring::npos && tt.find("&gt;") == Glib::ustring::npos) indclippedh->set_tooltip_text (tt); if (tt.find("&lt;") == Glib::ustring::npos && tt.find("&gt;") == Glib::ustring::npos) indclippedh->set_tooltip_text (tt);
else indclippedh->set_tooltip_markup (tt); else indclippedh->set_tooltip_markup (tt);
indclippeds = Gtk::manage (new Gtk::ToggleButton ()); indclippeds = Gtk::manage (new Gtk::ToggleButton ());
indclippeds->set_relief(Gtk::RELIEF_NONE); indclippeds->set_relief(Gtk::RELIEF_NONE);
indclippeds->add (*Gtk::manage (new RTImage ("warnsh.png"))); indclippeds->add (*Gtk::manage (new RTImage ("warnsh.png")));
tt = M("MAIN_TOOLTIP_INDCLIPPEDS"); tt = Glib::ustring::compose("%1\n%2 = %3",M("MAIN_TOOLTIP_INDCLIPPEDS"),M("MAIN_TOOLTIP_THRESHOLD"),options.shadowThreshold);
if (tt.find("&lt;") == Glib::ustring::npos && tt.find("&gt;") == Glib::ustring::npos) indclippeds->set_tooltip_text (tt); if (tt.find("&lt;") == Glib::ustring::npos && tt.find("&gt;") == Glib::ustring::npos) indclippeds->set_tooltip_text (tt);
else indclippeds->set_tooltip_markup (tt); else indclippeds->set_tooltip_markup (tt);

141
rtgui/previewmodepanel.cc Normal file
View File

@@ -0,0 +1,141 @@
/*
* This file is part of RawTherapee.
*
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "previewmodepanel.h"
#include "options.h"
#include "multilangmgr.h"
#include "imagearea.h"
#include "rtimage.h"
PreviewModePanel::PreviewModePanel (ImageArea* ia) : imageArea(ia) {
previewR = Gtk::manage (new Gtk::ToggleButton ("R"));
previewR->set_relief(Gtk::RELIEF_NONE);
previewR->set_tooltip_markup (M("MAIN_TOOLTIP_PREVIEWR"));
previewG = Gtk::manage (new Gtk::ToggleButton ("G"));
previewG->set_relief(Gtk::RELIEF_NONE);
previewG->set_tooltip_markup (M("MAIN_TOOLTIP_PREVIEWG"));
previewB = Gtk::manage (new Gtk::ToggleButton ("B"));
previewB->set_relief(Gtk::RELIEF_NONE);
previewB->set_tooltip_markup (M("MAIN_TOOLTIP_PREVIEWB"));
previewL = Gtk::manage (new Gtk::ToggleButton ("L"));
previewL->set_relief(Gtk::RELIEF_NONE);
previewL->set_tooltip_markup (M("MAIN_TOOLTIP_PREVIEWL"));
previewFocusMask = Gtk::manage (new Gtk::ToggleButton ("F"));
previewFocusMask->set_relief(Gtk::RELIEF_NONE);
previewFocusMask->set_tooltip_markup (M("MAIN_TOOLTIP_PREVIEWFOCUSMASK"));
previewFocusMask->hide();//TODO re-enable when Focus Mask is developed
previewR->set_active (false);
previewG->set_active (false);
previewB->set_active (false);
previewL->set_active (false);
previewFocusMask->set_active (false);
pack_start (*previewR, Gtk::PACK_SHRINK, 0);
pack_start (*previewG, Gtk::PACK_SHRINK, 0);
pack_start (*previewB, Gtk::PACK_SHRINK, 0);
pack_start (*previewL, Gtk::PACK_SHRINK, 0);
//pack_start (*previewFocusMask, Gtk::PACK_SHRINK, 0); //TODO re-enable when Focus Mask is developed
connR = previewR->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &PreviewModePanel::buttonToggled),previewR) );
connG = previewG->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &PreviewModePanel::buttonToggled),previewG) );
connB = previewB->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &PreviewModePanel::buttonToggled),previewB) );
connL = previewL->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &PreviewModePanel::buttonToggled),previewL) );
connFocusMask = previewFocusMask->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &PreviewModePanel::buttonToggled),previewFocusMask) );
//show_all ();
}
//TODO: use functions below for shortcuts
void PreviewModePanel::toggleR () {
}
void PreviewModePanel::toggleG () {
}
void PreviewModePanel::toggleB () {
}
void PreviewModePanel::toggleL () {
}
void PreviewModePanel::toggleFocusMask () {
}
void PreviewModePanel::buttonToggled (Gtk::ToggleButton* tbpreview) {
// only 0 or 1 button at a time can remain pressed
connR.block(true);
connG.block(true);
connB.block(true);
connL.block(true);
connFocusMask.block(true);
if (tbpreview==previewR){
//
previewG->set_active(false);
previewB->set_active(false);
previewL->set_active(false);
previewFocusMask->set_active(false);
}
if (tbpreview==previewG){
previewR->set_active(false);
//
previewB->set_active(false);
previewL->set_active(false);
previewFocusMask->set_active(false);
}
if (tbpreview==previewB){
previewR->set_active(false);
previewG->set_active(false);
//
previewL->set_active(false);
previewFocusMask->set_active(false);
}
if (tbpreview==previewL){
previewR->set_active(false);
previewG->set_active(false);
previewB->set_active(false);
//
previewFocusMask->set_active(false);
}
if (tbpreview==previewFocusMask){
previewR->set_active(false);
previewG->set_active(false);
previewB->set_active(false);
previewL->set_active(false);
//
}
connR.block(false);
connG.block(false);
connB.block(false);
connL.block(false);
connFocusMask.block(false);
imageArea->queue_draw ();
}

55
rtgui/previewmodepanel.h Normal file
View File

@@ -0,0 +1,55 @@
/*
* This file is part of RawTherapee.
*
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PREVIEWMODEPANEL_
#define _PREVIEWMODEPANEL_
#include <gtkmm.h>
class ImageArea;
class PreviewModePanel : public Gtk::HBox {
protected:
Gtk::ToggleButton* previewR;
Gtk::ToggleButton* previewG;
Gtk::ToggleButton* previewB;
Gtk::ToggleButton* previewL;
Gtk::ToggleButton* previewFocusMask;
ImageArea* imageArea;
public:
PreviewModePanel (ImageArea* ia);
void toggleR ();
void toggleG ();
void toggleB ();
void toggleL ();
void toggleFocusMask ();
sigc::connection connR, connB, connG, connL, connFocusMask;
void buttonToggled(Gtk::ToggleButton* tbpreview);
bool showR () { return previewR->get_active (); }
bool showG () { return previewG->get_active (); }
bool showB () { return previewB->get_active (); }
bool showL () { return previewL->get_active (); }
bool showFocusMask () { return previewFocusMask->get_active (); }
};
#endif