[Digikam-devel] extragear/graphics/digikam
Gilles Caulier
caulier.gilles at kdemail.net
Thu Jan 11 10:08:45 GMT 2007
SVN commit 622270 by cgilles:
digikam from trunk : Improvement of Brighness/Contrast/gamma image editor tool :
There is a new common widget for image editor plugin named ColorAlertWidget to handle pure white/black color with over/under exposed image. You can choose the pure white/black color mask to display and preview. The plugin will remember the settings between sesssion.
This new widget have been inspired of Photoshop PowerRetouche plugins (http://powerretouche.com)
There is a screenschot of new BCG tool in action at this url:
http://www.digikam.org/?q=node/23&size=_original
CCMAIL: digikam-devel at kde.org
M +25 -23 imageplugins/imageeffect_bcg.cpp
M +3 -3 imageplugins/imageeffect_bcg.h
M +48 -34 libs/dimg/filters/bcgmodifier.cpp
M +6 -0 libs/dimg/filters/bcgmodifier.h
M +2 -2 libs/widgets/imageplugins/Makefile.am
AM libs/widgets/imageplugins/coloralertwidget.cpp [License: GPL]
AM libs/widgets/imageplugins/coloralertwidget.h [License: GPL]
--- trunk/extragear/graphics/digikam/imageplugins/imageeffect_bcg.cpp #622269:622270
@@ -52,6 +52,7 @@
#include "imagewidget.h"
#include "histogramwidget.h"
#include "colorgradientwidget.h"
+#include "coloralertwidget.h"
#include "bcgmodifier.h"
#include "dimg.h"
@@ -167,19 +168,10 @@
gridSettings->addMultiCellWidget(label4, 7, 7, 0, 4);
gridSettings->addMultiCellWidget(m_gInput, 8, 8, 0, 4);
- m_overExposureIndicatorBox = new QCheckBox(i18n("Over exposure indicator"), gboxSettings);
- QWhatsThis::add( m_overExposureIndicatorBox, i18n("<p>If you enable this option, over-exposed pixels "
- "from the target image preview will be colored to black. "
- "This will not have an effect on the final rendering."));
- gridSettings->addMultiCellWidget(m_overExposureIndicatorBox, 9, 9, 0, 4);
+ m_colorAlertWidget = new Digikam::ColorAlertWidget("bcgadjust Tool Dialog", gboxSettings),
+ gridSettings->addMultiCellWidget(m_colorAlertWidget, 9, 9, 0, 4);
- m_underExposureIndicatorBox = new QCheckBox(i18n("Under exposure indicator"), gboxSettings);
- QWhatsThis::add( m_underExposureIndicatorBox, i18n("<p>If you enable this option, under-exposed pixels "
- "from the target image preview will be colored to white. "
- "This will not have an effect on the final rendering."));
- gridSettings->addMultiCellWidget(m_underExposureIndicatorBox, 10, 10, 0, 4);
-
- gridSettings->setRowStretch(11, 10);
+ gridSettings->setRowStretch(10, 10);
setUserAreaWidget(gboxSettings);
// -------------------------------------------------------------
@@ -193,20 +185,26 @@
connect(m_previewWidget, SIGNAL(spotPositionChangedFromTarget( const Digikam::DColor &, const QPoint & )),
this, SLOT(slotColorSelectedFromTarget( const Digikam::DColor & )));
- connect(m_bInput, SIGNAL(valueChanged (int)),
+ connect(m_bInput, SIGNAL(valueChanged(int)),
this, SLOT(slotTimer()));
- connect(m_cInput, SIGNAL(valueChanged (int)),
+ connect(m_cInput, SIGNAL(valueChanged(int)),
this, SLOT(slotTimer()));
- connect(m_gInput, SIGNAL(valueChanged (double)),
+ connect(m_gInput, SIGNAL(valueChanged(double)),
this, SLOT(slotTimer()));
- connect(m_overExposureIndicatorBox, SIGNAL(toggled (bool)),
+ connect(m_colorAlertWidget, SIGNAL(signalWhiteAlertToggled(bool)),
this, SLOT(slotEffect()));
- connect(m_underExposureIndicatorBox, SIGNAL(toggled (bool)),
+ connect(m_colorAlertWidget, SIGNAL(signalBlackAlertToggled(bool)),
this, SLOT(slotEffect()));
+
+ connect(m_colorAlertWidget, SIGNAL(signalWhiteAlertColorChanged(const QColor&)),
+ this, SLOT(slotEffect()));
+
+ connect(m_colorAlertWidget, SIGNAL(signalBlackAlertColorChanged(const QColor&)),
+ this, SLOT(slotEffect()));
connect(m_previewWidget, SIGNAL(signalResized()),
this, SLOT(slotEffect()));
@@ -284,11 +282,13 @@
{
kapp->setOverrideCursor( KCursor::waitCursor() );
- double b = (double)m_bInput->value()/250.0;
- double c = (double)(m_cInput->value()/100.0) + 1.00;
- double g = m_gInput->value();
- bool o = m_overExposureIndicatorBox->isChecked();
- bool u = m_underExposureIndicatorBox->isChecked();
+ double b = (double)m_bInput->value()/250.0;
+ double c = (double)(m_cInput->value()/100.0) + 1.00;
+ double g = m_gInput->value();
+ bool o = m_colorAlertWidget->whiteAlertIsChecked();
+ bool u = m_colorAlertWidget->blackAlertIsChecked();
+ QColor wh = m_colorAlertWidget->whiteAlertColor();
+ QColor bl = m_colorAlertWidget->blackAlertColor();
enableButtonOK( b != 0.0 || c != 1.0 || g != 1.0 );
@@ -307,7 +307,9 @@
Digikam::DImg preview(w, h, sb, a, m_destinationPreviewData);
Digikam::BCGModifier cmod;
cmod.setOverIndicator(o);
+ cmod.setOverIndicatorColor(wh);
cmod.setUnderIndicator(u);
+ cmod.setUnderIndicatorColor(bl);
cmod.setGamma(g);
cmod.setBrightness(b);
cmod.setContrast(c);
@@ -331,7 +333,7 @@
double b = (double)m_bInput->value()/250.0;
double c = (double)(m_cInput->value()/100.0) + 1.00;
- double g = m_gInput->value() + 1.00;
+ double g = m_gInput->value();
iface->setOriginalBCG(b, c, g);
kapp->restoreOverrideCursor();
--- trunk/extragear/graphics/digikam/imageplugins/imageeffect_bcg.h #622269:622270
@@ -39,6 +39,7 @@
{
class HistogramWidget;
class ColorGradientWidget;
+class ColorAlertWidget;
class ImageWidget;
class DColor;
}
@@ -89,13 +90,12 @@
QHButtonGroup *m_scaleBG;
- QCheckBox *m_overExposureIndicatorBox;
- QCheckBox *m_underExposureIndicatorBox;
-
KIntNumInput *m_bInput;
KIntNumInput *m_cInput;
KDoubleNumInput *m_gInput;
+ Digikam::ColorAlertWidget *m_colorAlertWidget;
+
Digikam::ImageWidget *m_previewWidget;
Digikam::ColorGradientWidget *m_hGradient;
--- trunk/extragear/graphics/digikam/libs/dimg/filters/bcgmodifier.cpp #622269:622270
@@ -28,9 +28,14 @@
#include <cstdio>
#include <cmath>
+// Qt includes.
+
+#include <qcolor.h>
+
// Local includes.
#include "dimg.h"
+#include "dcolor.h"
#include "bcgmodifier.h"
namespace Digikam
@@ -42,17 +47,22 @@
BCGModifierPriv()
{
- modified = false;
- overIndicator = false;
- underIndicator = false;
+ modified = false;
+ overIndicator = false;
+ underIndicator = false;
+ overIndicatorColor = Qt::black;
+ underIndicatorColor = Qt::white;
}
- bool overIndicator;
- bool underIndicator;
- bool modified;
+ bool overIndicator;
+ bool underIndicator;
+ bool modified;
- int map16[65536];
- int map[256];
+ int map16[65536];
+ int map[256];
+
+ QColor overIndicatorColor;
+ QColor underIndicatorColor;
};
BCGModifier::BCGModifier()
@@ -81,6 +91,16 @@
d->underIndicator = underIndicator;
}
+void BCGModifier::setOverIndicatorColor(const QColor& oc)
+{
+ d->overIndicatorColor = oc;
+}
+
+void BCGModifier::setUnderIndicatorColor(const QColor& uc)
+{
+ d->underIndicatorColor = uc;
+}
+
void BCGModifier::reset()
{
// initialize to linear mapping
@@ -91,27 +111,21 @@
for (int i=0; i<256; i++)
d->map[i] = i;
- d->modified = false;
- d->overIndicator = false;
- d->underIndicator = false;
+ d->modified = false;
+ d->overIndicator = false;
+ d->underIndicator = false;
+ d->overIndicatorColor = Qt::black;
+ d->underIndicatorColor = Qt::white;
}
void BCGModifier::applyBCG(DImg& image)
{
- /*
- What is the idea with setting the values when overIndicator is true?
- When the correct value is beyond the upper limit,
- we set the value to be negative.
- When the next function is called (setGamma, setBrightness, setContrast),
- it has the opportunity to correct the excess, or the value
- will again be set to its negative.
- When the correction arrays are applied, all colors with
- negative values in the arrays will be to black.
- */
-
if (!d->modified || image.isNull())
return;
+ DColor overColor(d->overIndicatorColor, image.sixteenBit());
+ DColor underColor(d->underIndicatorColor, image.sixteenBit());
+
uint size = image.width()*image.height();
if (!image.sixteenBit()) // 8 bits image.
@@ -123,16 +137,16 @@
if (d->overIndicator && (d->map[data[0]] > 255 &&
d->map[data[1]] > 255 && d->map[data[2]] > 255))
{
- data[0] = 0;
- data[1] = 0;
- data[2] = 0;
+ data[0] = (uchar)overColor.blue();
+ data[1] = (uchar)overColor.green();
+ data[2] = (uchar)overColor.red();
}
else if (d->underIndicator && (d->map[data[0]] < 0 &&
d->map[data[1]] < 0 && d->map[data[2]] < 0))
{
- data[0] = 255;
- data[1] = 255;
- data[2] = 255;
+ data[0] = (uchar)underColor.blue();
+ data[1] = (uchar)underColor.green();
+ data[2] = (uchar)underColor.red();
}
else
{
@@ -153,16 +167,16 @@
if (d->overIndicator && (d->map16[data[0]] > 65535 &&
d->map16[data[1]] > 65535 && d->map16[data[2]] > 65535))
{
- data[0] = 0;
- data[1] = 0;
- data[2] = 0;
+ data[0] = (ushort)overColor.blue();
+ data[1] = (ushort)overColor.green();
+ data[2] = (ushort)overColor.red();
}
else if (d->underIndicator && (d->map16[data[0]] < 0 &&
d->map16[data[1]] < 0 && d->map16[data[2]] < 0))
{
- data[0] = 65535;
- data[1] = 65535;
- data[2] = 65535;
+ data[0] = (ushort)underColor.blue();
+ data[1] = (ushort)underColor.green();
+ data[2] = (ushort)underColor.red();
}
else
{
--- trunk/extragear/graphics/digikam/libs/dimg/filters/bcgmodifier.h #622269:622270
@@ -27,6 +27,8 @@
#include "digikam_export.h"
+class QColor;
+
namespace Digikam
{
@@ -45,6 +47,10 @@
void setOverIndicator(bool overIndicator);
void setUnderIndicator(bool underIndicator);
+
+ void setOverIndicatorColor(const QColor& oc);
+ void setUnderIndicatorColor(const QColor& uc);
+
void setGamma(double val);
void setBrightness(double val);
void setContrast(double val);
--- trunk/extragear/graphics/digikam/libs/widgets/imageplugins/Makefile.am #622269:622270
@@ -4,7 +4,7 @@
libimagepluginswidgets_la_SOURCES = imageregionwidget.cpp imagepaniconwidget.cpp imageselectionwidget.cpp \
imageguidewidget.cpp imagepannelwidget.cpp imagewidget.cpp \
- listboxpreviewitem.cpp
+ listboxpreviewitem.cpp coloralertwidget.cpp
libimagepluginswidgets_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
@@ -17,6 +17,6 @@
digikaminclude_HEADERS = imageregionwidget.h imagepaniconwidget.h imagewidget.h \
imageselectionwidget.h imagepannelwidget.h imageguidewidget.h \
- listboxpreviewitem.h
+ listboxpreviewitem.h coloralertwidget.h
digikamincludedir = $(includedir)/digikam
** trunk/extragear/graphics/digikam/libs/widgets/imageplugins/coloralertwidget.cpp #property svn:eol-style
+ native
** trunk/extragear/graphics/digikam/libs/widgets/imageplugins/coloralertwidget.h #property svn:eol-style
+ native
More information about the Digikam-devel
mailing list