summaryrefslogtreecommitdiffstats
path: root/src/imageplugins/antivignetting
diff options
context:
space:
mode:
Diffstat (limited to 'src/imageplugins/antivignetting')
-rw-r--r--src/imageplugins/antivignetting/Makefile.am34
-rw-r--r--src/imageplugins/antivignetting/antivignetting.cpp149
-rw-r--r--src/imageplugins/antivignetting/antivignetting.h62
-rw-r--r--src/imageplugins/antivignetting/antivignettingtool.cpp378
-rw-r--r--src/imageplugins/antivignetting/antivignettingtool.h92
-rw-r--r--src/imageplugins/antivignetting/digikamimageplugin_antivignetting.desktop50
-rw-r--r--src/imageplugins/antivignetting/digikamimageplugin_antivignetting_ui.rc20
-rw-r--r--src/imageplugins/antivignetting/imageeffect_antivignetting.cpp380
-rw-r--r--src/imageplugins/antivignetting/imageeffect_antivignetting.h79
-rw-r--r--src/imageplugins/antivignetting/imageplugin_antivignetting.cpp70
-rw-r--r--src/imageplugins/antivignetting/imageplugin_antivignetting.h57
11 files changed, 1371 insertions, 0 deletions
diff --git a/src/imageplugins/antivignetting/Makefile.am b/src/imageplugins/antivignetting/Makefile.am
new file mode 100644
index 00000000..54539672
--- /dev/null
+++ b/src/imageplugins/antivignetting/Makefile.am
@@ -0,0 +1,34 @@
+METASOURCES = AUTO
+
+INCLUDES = -I$(top_srcdir)/src/utilities/imageeditor/editor \
+ -I$(top_srcdir)/src/utilities/imageeditor/canvas \
+ -I$(top_srcdir)/src/libs/histogram \
+ -I$(top_srcdir)/src/libs/levels \
+ -I$(top_srcdir)/src/libs/curves \
+ -I$(top_srcdir)/src/libs/whitebalance \
+ -I$(top_srcdir)/src/libs/widgets/common \
+ -I$(top_srcdir)/src/libs/widgets/iccprofiles \
+ -I$(top_srcdir)/src/libs/widgets/imageplugins \
+ -I$(top_srcdir)/src/libs/dialogs \
+ -I$(top_srcdir)/src/libs/dimg \
+ -I$(top_srcdir)/src/libs/dmetadata \
+ -I$(top_srcdir)/src/libs/dimg/filters \
+ -I$(top_srcdir)/src/digikam \
+ $(LIBKDCRAW_CFLAGS) \
+ $(all_includes)
+
+digikamimageplugin_antivignetting_la_SOURCES = imageplugin_antivignetting.cpp \
+ antivignettingtool.cpp antivignetting.cpp
+
+digikamimageplugin_antivignetting_la_LIBADD = $(LIB_TDEPARTS) \
+ $(top_builddir)/src/digikam/libdigikam.la
+
+digikamimageplugin_antivignetting_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -ltdecore -ltdeui $(LIB_TQT) -ltdefx -lkdcraw -ltdeio
+
+kde_services_DATA = digikamimageplugin_antivignetting.desktop
+
+kde_module_LTLIBRARIES = digikamimageplugin_antivignetting.la
+
+rcdir = $(kde_datadir)/digikam
+rc_DATA = digikamimageplugin_antivignetting_ui.rc
+
diff --git a/src/imageplugins/antivignetting/antivignetting.cpp b/src/imageplugins/antivignetting/antivignetting.cpp
new file mode 100644
index 00000000..dec0a9ea
--- /dev/null
+++ b/src/imageplugins/antivignetting/antivignetting.cpp
@@ -0,0 +1,149 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2005-05-25
+ * Description : Antivignetting threaded image filter.
+ *
+ * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * Original AntiVignetting algorithm copyrighted 2003 by
+ * John Walker from 'pnmctrfilt' implementation. See
+ * http://www.fourmilab.ch/netpbm/pnmctrfilt for more
+ * information.
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+// C++ includes.
+
+#include <cmath>
+#include <cstdlib>
+
+// Local includes.
+
+#include "dimg.h"
+#include "dimgimagefilters.h"
+#include "antivignetting.h"
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+AntiVignetting::AntiVignetting(Digikam::DImg *orgImage, TQObject *parent, double density,
+ double power, double radius, int xshift, int yshift, bool normalize)
+ : Digikam::DImgThreadedFilter(orgImage, parent, "AntiVignetting")
+{
+ m_density = density;
+ m_power = power;
+ m_radius = radius;
+ m_xshift = xshift;
+ m_yshift = yshift;
+ m_normalize = normalize;
+
+ initFilter();
+}
+
+// This method is inspired from John Walker 'pnmctrfilt' algorithm code.
+
+void AntiVignetting::filterImage(void)
+{
+ int progress;
+ int col, row, xd, td, yd, p;
+ int i, xsize, ysize, diagonal, erad, xctr, yctr;
+ double *ldens;
+
+ uchar* NewBits = m_destImage.bits();
+ uchar* data = m_orgImage.bits();
+
+ unsigned short* NewBits16 = (unsigned short*)m_destImage.bits();
+ unsigned short* data16 = (unsigned short*)m_orgImage.bits();
+
+ int Width = m_orgImage.width();
+ int Height = m_orgImage.height();
+
+ // Determine the radius of the filter. This is the half diagonal
+ // measure of the image multiplied by the command line radius factor.
+
+ xsize = (Height + 1) / 2;
+ ysize = (Width + 1) / 2;
+ erad = (int)((sqrt((xsize * xsize) + (ysize * ysize)) + 0.5) * m_radius);
+
+ // Build the in-memory table which maps distance from the
+ // center of the image (as adjusted by the X and Y offset,
+ // if any) to the density of the filter at this remove. This
+ // table needs to be as large as the diagonal from the
+ // (possibly offset) center to the most distant corner
+ // of the image.
+
+ xsize = ((Height + 1) / 2) + abs(m_xshift);
+ ysize = ((Width + 1) / 2) + abs(m_yshift);
+ diagonal = ((int) (sqrt((xsize * xsize) + (ysize * ysize)) + 0.5)) + 1;
+
+ ldens = new double[diagonal];
+
+ for (i = 0 ; !m_cancel && (i < diagonal) ; i++)
+ {
+ if ( i >= erad )
+ ldens[i] = 1;
+ else
+ ldens[i] = (1.0 + (m_density - 1) * pow(1.0 - (((double) i) / (erad - 1)), m_power));
+ }
+
+ xctr = ((Height + 1) / 2) + m_xshift;
+ yctr = ((Width + 1) / 2) + m_yshift;
+
+ for (row = 0 ; !m_cancel && (row < Width) ; row++)
+ {
+ yd = abs(yctr - row);
+
+ for (col = 0 ; !m_cancel && (col < Height) ; col++)
+ {
+ p = (col * Width + row)*4;
+
+ xd = abs(xctr - col);
+ td = (int) (sqrt((xd * xd) + (yd * yd)) + 0.5);
+
+ if (!m_orgImage.sixteenBit()) // 8 bits image
+ {
+ NewBits[ p ] = (uchar)(data[ p ] / ldens[td]);
+ NewBits[p+1] = (uchar)(data[p+1] / ldens[td]);
+ NewBits[p+2] = (uchar)(data[p+2] / ldens[td]);
+ NewBits[p+3] = data[p+3];
+ }
+ else // 16 bits image.
+ {
+ NewBits16[ p ] = (unsigned short)(data16[ p ] / ldens[td]);
+ NewBits16[p+1] = (unsigned short)(data16[p+1] / ldens[td]);
+ NewBits16[p+2] = (unsigned short)(data16[p+2] / ldens[td]);
+ NewBits16[p+3] = data16[p+3];
+ }
+ }
+
+ // Update the progress bar in dialog.
+ progress = (int)(((double)row * 100.0) / Width);
+ if (progress%5 == 0)
+ postProgress( progress );
+ }
+
+ // Normalize colors for a best rendering.
+ if (m_normalize)
+ {
+ Digikam::DImgImageFilters filters;
+ filters.normalizeImage(m_destImage.bits(), Width, Height, m_destImage.sixteenBit());
+ }
+
+ delete [] ldens;
+}
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
diff --git a/src/imageplugins/antivignetting/antivignetting.h b/src/imageplugins/antivignetting/antivignetting.h
new file mode 100644
index 00000000..f5311da0
--- /dev/null
+++ b/src/imageplugins/antivignetting/antivignetting.h
@@ -0,0 +1,62 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2005-05-25
+ * Description : Antivignetting threaded image filter.
+ *
+ * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+#ifndef ANTIVIGNETTING_H
+#define ANTIVIGNETTING_H
+
+// Digikam includes.
+
+#include "dimgthreadedfilter.h"
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+class AntiVignetting : public Digikam::DImgThreadedFilter
+{
+
+public:
+
+ AntiVignetting(Digikam::DImg *orgImage, TQObject *parent=0, double density=2.0,
+ double power=1.0, double radius=1.0, int xshift=0, int yshift=0, bool normalize=true);
+
+ ~AntiVignetting(){};
+
+private:
+
+ virtual void filterImage(void);
+
+private:
+
+ bool m_normalize;
+
+ int m_xshift;
+ int m_yshift;
+
+ double m_density;
+ double m_power;
+ double m_radius;
+};
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
+
+#endif /* ANTIVIGNETTING_H */
diff --git a/src/imageplugins/antivignetting/antivignettingtool.cpp b/src/imageplugins/antivignetting/antivignettingtool.cpp
new file mode 100644
index 00000000..d8f211c7
--- /dev/null
+++ b/src/imageplugins/antivignetting/antivignettingtool.cpp
@@ -0,0 +1,378 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2004-12-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqlabel.h>
+#include <tqwhatsthis.h>
+#include <tqlayout.h>
+#include <tqimage.h>
+#include <tqpixmap.h>
+#include <tqpainter.h>
+#include <tqpen.h>
+#include <tqtabwidget.h>
+
+// KDE includes.
+
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdeaboutdata.h>
+#include <kiconloader.h>
+#include <tdeapplication.h>
+#include <kstandarddirs.h>
+#include <kseparator.h>
+
+// LibKDcraw includes.
+
+#include <libkdcraw/rnuminput.h>
+
+// Local includes.
+
+#include "daboutdata.h"
+#include "ddebug.h"
+#include "bcgmodifier.h"
+#include "imageiface.h"
+#include "imagewidget.h"
+#include "editortoolsettings.h"
+#include "dimgimagefilters.h"
+#include "antivignetting.h"
+#include "antivignettingtool.h"
+#include "antivignettingtool.moc"
+
+using namespace KDcrawIface;
+using namespace Digikam;
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+AntiVignettingTool::AntiVignettingTool(TQObject* parent)
+ : EditorToolThreaded(parent)
+{
+ setName("antivignettings");
+ setToolName(i18n("Vignetting Correction"));
+ setToolIcon(SmallIcon("antivignetting"));
+
+ m_previewWidget = new ImageWidget("antivignetting Tool", 0, TQString(),
+ false, ImageGuideWidget::HVGuideMode, false);
+
+ setToolView(m_previewWidget);
+
+ // -------------------------------------------------------------
+
+ m_gboxSettings = new EditorToolSettings(EditorToolSettings::Default|
+ EditorToolSettings::Ok|
+ EditorToolSettings::Cancel);
+ TQGridLayout* grid = new TQGridLayout(m_gboxSettings->plainPage(), 14, 2);
+
+ m_maskPreviewLabel = new TQLabel( m_gboxSettings->plainPage() );
+ m_maskPreviewLabel->setAlignment ( TQt::AlignHCenter | TQt::AlignVCenter );
+ TQWhatsThis::add( m_maskPreviewLabel, i18n("<p>You can see here a thumbnail preview of the anti-vignetting "
+ "mask applied to the image.") );
+
+ // -------------------------------------------------------------
+
+ TQLabel *label1 = new TQLabel(i18n("Density:"), m_gboxSettings->plainPage());
+
+ m_densityInput = new RDoubleNumInput(m_gboxSettings->plainPage());
+ m_densityInput->setPrecision(1);
+ m_densityInput->setRange(1.0, 20.0, 0.1);
+ m_densityInput->setDefaultValue(2.0);
+ TQWhatsThis::add( m_densityInput, i18n("<p>This value controls the degree of intensity attenuation by the filter "
+ "at its point of maximum density."));
+
+ // -------------------------------------------------------------
+
+ TQLabel *label2 = new TQLabel(i18n("Power:"), m_gboxSettings->plainPage());
+
+ m_powerInput = new RDoubleNumInput(m_gboxSettings->plainPage());
+ m_powerInput->setPrecision(1);
+ m_powerInput->setRange(0.1, 2.0, 0.1);
+ m_powerInput->setDefaultValue(1.0);
+ TQWhatsThis::add( m_powerInput, i18n("<p>This value is used as the exponent controlling the fall-off in density "
+ "from the center of the filter to the periphery."));
+
+ // -------------------------------------------------------------
+
+ TQLabel *label3 = new TQLabel(i18n("Radius:"), m_gboxSettings->plainPage());
+
+ m_radiusInput = new RDoubleNumInput(m_gboxSettings->plainPage());
+ m_radiusInput->setPrecision(1);
+ m_radiusInput->setRange(-100.0, 100.0, 0.1);
+ m_radiusInput->setDefaultValue(1.0);
+ TQWhatsThis::add( m_radiusInput, i18n("<p>This value is the radius of the center filter. It is a multiple of the "
+ "half-diagonal measure of the image, at which the density of the filter falls "
+ "to zero."));
+
+ KSeparator *line = new KSeparator(Horizontal, m_gboxSettings->plainPage());
+
+ // -------------------------------------------------------------
+
+ TQLabel *label4 = new TQLabel(i18n("Brightness:"), m_gboxSettings->plainPage());
+
+ m_brightnessInput = new RIntNumInput(m_gboxSettings->plainPage());
+ m_brightnessInput->setRange(0, 100, 1);
+ m_brightnessInput->setDefaultValue(0);
+ TQWhatsThis::add( m_brightnessInput, i18n("<p>Set here the brightness re-adjustment of the target image."));
+
+ // -------------------------------------------------------------
+
+ TQLabel *label5 = new TQLabel(i18n("Contrast:"), m_gboxSettings->plainPage());
+
+ m_contrastInput = new RIntNumInput(m_gboxSettings->plainPage());
+ m_contrastInput->setRange(0, 100, 1);
+ m_contrastInput->setDefaultValue(0);
+ TQWhatsThis::add( m_contrastInput, i18n("<p>Set here the contrast re-adjustment of the target image."));
+
+ // -------------------------------------------------------------
+
+ TQLabel *label6 = new TQLabel(i18n("Gamma:"), m_gboxSettings->plainPage());
+
+ m_gammaInput = new RDoubleNumInput(m_gboxSettings->plainPage());
+ m_gammaInput->setPrecision(2);
+ m_gammaInput->setRange(0.1, 3.0, 0.01);
+ m_gammaInput->setDefaultValue(1.0);
+ TQWhatsThis::add( m_gammaInput, i18n("<p>Set here the gamma re-adjustment of the target image."));
+
+ grid->addMultiCellWidget(m_maskPreviewLabel, 0, 0, 0, 2);
+ grid->addMultiCellWidget(label1, 1, 1, 0, 2);
+ grid->addMultiCellWidget(m_densityInput, 2, 2, 0, 2);
+ grid->addMultiCellWidget(label2, 3, 3, 0, 2);
+ grid->addMultiCellWidget(m_powerInput, 4, 4, 0, 2);
+ grid->addMultiCellWidget(label3, 5, 5, 0, 2);
+ grid->addMultiCellWidget(m_radiusInput, 6, 6, 0, 2);
+ grid->addMultiCellWidget(line, 7, 7, 0, 2);
+ grid->addMultiCellWidget(label4, 8, 8, 0, 2);
+ grid->addMultiCellWidget(m_brightnessInput, 9, 9, 0, 2);
+ grid->addMultiCellWidget(label5, 10, 10, 0, 2);
+ grid->addMultiCellWidget(m_contrastInput, 11, 11, 0, 2);
+ grid->addMultiCellWidget(label6, 12, 12, 0, 2);
+ grid->addMultiCellWidget(m_gammaInput, 13, 13, 0, 2);
+ grid->setRowStretch(14, 10);
+ grid->setMargin(m_gboxSettings->spacingHint());
+ grid->setSpacing(m_gboxSettings->spacingHint());
+
+ setToolSettings(m_gboxSettings);
+ init();
+
+ // -------------------------------------------------------------
+
+ connect(m_densityInput, TQ_SIGNAL(valueChanged(double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_powerInput, TQ_SIGNAL(valueChanged(double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_radiusInput, TQ_SIGNAL(valueChanged(double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_brightnessInput, TQ_SIGNAL(valueChanged(int)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_contrastInput, TQ_SIGNAL(valueChanged(int)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_gammaInput, TQ_SIGNAL(valueChanged(double)),
+ this, TQ_SLOT(slotTimer()));
+}
+
+AntiVignettingTool::~AntiVignettingTool()
+{
+}
+
+void AntiVignettingTool::renderingFinished()
+{
+ m_densityInput->setEnabled(true);
+ m_powerInput->setEnabled(true);
+ m_radiusInput->setEnabled(true);
+ m_brightnessInput->setEnabled(true);
+ m_contrastInput->setEnabled(true);
+ m_gammaInput->setEnabled(true);
+}
+
+void AntiVignettingTool::readSettings()
+{
+ TDEConfig* config = kapp->config();
+ config->setGroup("antivignettings Tool");
+
+ m_densityInput->blockSignals(true);
+ m_powerInput->blockSignals(true);
+ m_radiusInput->blockSignals(true);
+ m_brightnessInput->blockSignals(true);
+ m_contrastInput->blockSignals(true);
+ m_gammaInput->blockSignals(true);
+
+ m_densityInput->setValue(config->readDoubleNumEntry("DensityAjustment", m_densityInput->defaultValue()));
+ m_powerInput->setValue(config->readDoubleNumEntry("PowerAjustment", m_powerInput->defaultValue()));
+ m_radiusInput->setValue(config->readDoubleNumEntry("RadiusAjustment", m_radiusInput->defaultValue()));
+ m_brightnessInput->setValue(config->readNumEntry("BrightnessAjustment", m_brightnessInput->defaultValue()));
+ m_contrastInput->setValue(config->readNumEntry("ContrastAjustment", m_contrastInput->defaultValue()));
+ m_gammaInput->setValue(config->readDoubleNumEntry("GammaAjustment", m_gammaInput->defaultValue()));
+
+ m_densityInput->blockSignals(false);
+ m_powerInput->blockSignals(false);
+ m_radiusInput->blockSignals(false);
+ m_brightnessInput->blockSignals(false);
+ m_contrastInput->blockSignals(false);
+ m_gammaInput->blockSignals(false);
+
+ slotEffect();
+}
+
+void AntiVignettingTool::writeSettings()
+{
+ TDEConfig* config = kapp->config();
+ config->setGroup("antivignettings Tool");
+ config->writeEntry("DensityAjustment", m_densityInput->value());
+ config->writeEntry("PowerAjustment", m_powerInput->value());
+ config->writeEntry("RadiusAjustment", m_radiusInput->value());
+ config->writeEntry("BrightnessAjustment", m_brightnessInput->value());
+ config->writeEntry("ContrastAjustment", m_contrastInput->value());
+ config->writeEntry("GammaAjustment", m_gammaInput->value());
+ m_previewWidget->writeSettings();
+ config->sync();
+}
+
+void AntiVignettingTool::slotResetSettings()
+{
+ m_densityInput->blockSignals(true);
+ m_powerInput->blockSignals(true);
+ m_radiusInput->blockSignals(true);
+ m_brightnessInput->blockSignals(true);
+ m_contrastInput->blockSignals(true);
+ m_gammaInput->blockSignals(true);
+
+ m_densityInput->slotReset();
+ m_powerInput->slotReset();
+ m_radiusInput->slotReset();
+ m_brightnessInput->slotReset();
+ m_contrastInput->slotReset();
+ m_gammaInput->slotReset();
+
+ m_densityInput->blockSignals(false);
+ m_powerInput->blockSignals(false);
+ m_radiusInput->blockSignals(false);
+ m_brightnessInput->blockSignals(false);
+ m_contrastInput->blockSignals(false);
+ m_gammaInput->blockSignals(false);
+}
+
+void AntiVignettingTool::prepareEffect()
+{
+ m_densityInput->setEnabled(false);
+ m_powerInput->setEnabled(false);
+ m_radiusInput->setEnabled(false);
+ m_brightnessInput->setEnabled(false);
+ m_contrastInput->setEnabled(false);
+ m_gammaInput->setEnabled(false);
+
+ double d = m_densityInput->value();
+ double p = m_powerInput->value();
+ double r = m_radiusInput->value();
+
+ ImageIface* iface = m_previewWidget->imageIface();
+ uchar *data = iface->getOriginalImage();
+ int orgWidth = iface->originalWidth();
+ int orgHeight = iface->originalHeight();
+ TQSize ps(orgWidth, orgHeight);
+ ps.scale( TQSize(120, 120), TQSize::ScaleMin );
+
+ // Calc mask preview.
+ DImg preview(ps.width(), ps.height(), false);
+ memset(preview.bits(), 255, preview.numBytes());
+ AntiVignetting maskPreview(&preview, 0L, d, p, r, 0, 0, false);
+ TQPixmap pix = maskPreview.getTargetImage().convertToPixmap();
+ TQPainter pt(&pix);
+ pt.setPen( TQPen(TQt::black, 1) );
+ pt.drawRect( 0, 0, pix.width(), pix.height() );
+ pt.end();
+ m_maskPreviewLabel->setPixmap( pix );
+
+ DImg orgImage(orgWidth, orgHeight, iface->originalSixteenBit(),
+ iface->originalHasAlpha(), data);
+ delete [] data;
+
+ setFilter(dynamic_cast<DImgThreadedFilter*>(new AntiVignetting(&orgImage, this, d, p, r, 0, 0, true)));
+}
+
+void AntiVignettingTool::prepareFinal()
+{
+ m_densityInput->setEnabled(false);
+ m_powerInput->setEnabled(false);
+ m_radiusInput->setEnabled(false);
+ m_brightnessInput->setEnabled(false);
+ m_contrastInput->setEnabled(false);
+ m_gammaInput->setEnabled(false);
+
+ double d = m_densityInput->value();
+ double p = m_powerInput->value();
+ double r = m_radiusInput->value();
+
+ ImageIface iface(0, 0);
+
+ uchar *data = iface.getOriginalImage();
+ DImg orgImage(iface.originalWidth(), iface.originalHeight(), iface.originalSixteenBit(),
+ iface.originalHasAlpha(), data);
+ delete [] data;
+
+ setFilter(dynamic_cast<DImgThreadedFilter*>(new AntiVignetting(&orgImage, this, d, p, r, 0, 0, true)));
+}
+
+void AntiVignettingTool::putPreviewData(void)
+{
+ ImageIface* iface = m_previewWidget->imageIface();
+ DImg imDest = filter()->getTargetImage();
+
+ // Adjust Image BCG.
+
+ double b = (double)(m_brightnessInput->value() / 100.0);
+ double c = (double)(m_contrastInput->value() / 100.0) + (double)(1.00);
+ double g = m_gammaInput->value();
+
+ BCGModifier cmod;
+ cmod.setGamma(g);
+ cmod.setBrightness(b);
+ cmod.setContrast(c);
+ cmod.applyBCG(imDest);
+
+ iface->putPreviewImage((imDest.smoothScale(iface->previewWidth(),
+ iface->previewHeight())).bits());
+ m_previewWidget->updatePreview();
+}
+
+void AntiVignettingTool::putFinalData(void)
+{
+ ImageIface iface(0, 0);
+
+ iface.putOriginalImage(i18n("Vignetting Correction"),
+ filter()->getTargetImage().bits());
+
+ double b = (double)(m_brightnessInput->value() / 100.0);
+ double c = (double)(m_contrastInput->value() / 100.0) + (double)(1.00);
+ double g = m_gammaInput->value();
+
+ // Adjust Image BCG.
+ iface.setOriginalBCG(b, c, g);
+}
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
diff --git a/src/imageplugins/antivignetting/antivignettingtool.h b/src/imageplugins/antivignetting/antivignettingtool.h
new file mode 100644
index 00000000..467a19da
--- /dev/null
+++ b/src/imageplugins/antivignetting/antivignettingtool.h
@@ -0,0 +1,92 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2005-05-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+#ifndef ANTIVIGNETTINGTOOL_H
+#define ANTIVIGNETTINGTOOL_H
+
+// Digikam includes.
+
+#include "editortool.h"
+
+class TQLabel;
+
+namespace KDcrawIface
+{
+class RIntNumInput;
+class RDoubleNumInput;
+}
+
+namespace Digikam
+{
+class EditorToolSettings;
+class ImageWidget;
+}
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+class AntiVignettingTool : public Digikam::EditorToolThreaded
+{
+ TQ_OBJECT
+
+
+public:
+
+ AntiVignettingTool(TQObject *parent);
+ ~AntiVignettingTool();
+
+private slots:
+
+ void slotResetSettings();
+
+private:
+
+ void writeSettings();
+ void readSettings();
+ void prepareEffect();
+ void prepareFinal();
+ void putPreviewData();
+ void putFinalData();
+ void renderingFinished();
+
+private:
+
+ TQLabel *m_maskPreviewLabel;
+
+ KDcrawIface::RIntNumInput *m_brightnessInput;
+ KDcrawIface::RIntNumInput *m_contrastInput;
+
+ KDcrawIface::RDoubleNumInput *m_gammaInput;
+ KDcrawIface::RDoubleNumInput *m_densityInput;
+ KDcrawIface::RDoubleNumInput *m_powerInput;
+ KDcrawIface::RDoubleNumInput *m_radiusInput;
+
+ Digikam::ImageWidget *m_previewWidget;
+
+ Digikam::EditorToolSettings *m_gboxSettings;
+};
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
+
+#endif /* ANTIVIGNETTINGTOOL_H */
diff --git a/src/imageplugins/antivignetting/digikamimageplugin_antivignetting.desktop b/src/imageplugins/antivignetting/digikamimageplugin_antivignetting.desktop
new file mode 100644
index 00000000..f70a4752
--- /dev/null
+++ b/src/imageplugins/antivignetting/digikamimageplugin_antivignetting.desktop
@@ -0,0 +1,50 @@
+[Desktop Entry]
+Name=ImagePlugin_AntiVignetting
+Name[bg]=Приставка за снимки - Премахване на винетиране
+Name[da]=Billedplugin_Anti-vignettering
+Name[el]=ΠρόσθετοΕικόνας_Αντισκίασης
+Name[fi]=ReunatummentumienPoisto
+Name[hr]=Uklanjanje vinjeta
+Name[it]=PluginImmagini_Antivignettatura
+Name[nl]=Afbeeldingsplugin_Antivignetting
+Name[sr]=Девињетизација
+Name[sr@Latn]=Devinjetizacija
+Name[sv]=Insticksprogram för antivinjettering
+Name[tr]=ResimEklentisi_KenarKararmalarınıDüzelt
+Name[xx]=xxImagePlugin_AntiVignettingxx
+Type=Service
+X-TDE-ServiceTypes=Digikam/ImagePlugin
+Encoding=UTF-8
+Comment=Anti Vignetting image effect plugin for digiKam
+Comment[bg]=Приставка на digiKam за намаляване на винетирането на снимки
+Comment[ca]=Connector pel digiKam d'efecte anti-vinyetatge
+Comment[da]=Anti-vignetteringsplugin for Digikam
+Comment[de]=digiKam-Modul zur Reduzierung von Vignettierung im Bild
+Comment[el]=Πρόσθετο εφέ αντισκίασης εικόνας για το digiKam
+Comment[es]=Un plugin para digiKam para eliminar efectos tipo "Vignetting"
+Comment[et]=DigiKami pildi vinjeti kohendamise plugin
+Comment[fa]=وصلۀ جلوۀ تصویر ضد عکس برای digiKam
+Comment[fi]=Keskialueen portaaton tummennus
+Comment[gl]=Un plugin de digiKam para efeitos antiviñeta de imaxe
+Comment[hr]=digiKam dodatak za efekt protiv vinjeta
+Comment[is]=Íforrit fyrir digiKam sem minnkar linsuskyggingu í hornum
+Comment[it]=Plugin per l'effetto delle immagini di antivignettatura per digiKam
+Comment[ja]=digiKam 口径食補正プラグイン
+Comment[nds]=digiKam-Bildeffektmoduul gegen Randschaddens
+Comment[nl]=Digikam-plugin voor anti-vignetting
+Comment[pa]=ਡਿਜ਼ੀਕੈਮ ਲਈ ਐਂਟੀ ਵੀਜਨਿੰਟ ਚਿੱਤਰ ਪਰਭਾਵ ਪਲੱਗਇਨ
+Comment[pl]=Wtyczka do programu digiKam usuwająca efekt winietowania
+Comment[pt]=Um 'plugin' do digiKam para efeitos anti-vinheta de imagem
+Comment[pt_BR]=Plugin de efeito anti-Vignetting para o digiKam
+Comment[ru]=Модуль эффекта анти-виньетирования изображения для digiKam
+Comment[sk]=Plugin korekcie vignetácie obrázku pre digiKam
+Comment[sr]=digiKam-ов прикључак за ефекат девињетизације
+Comment[sr@Latn]=digiKam-ov priključak za efekat devinjetizacije
+Comment[sv]=Digikam insticksprogram för antivinjetteringsbildeffekt
+Comment[tr]=digiKam için kenar kararmalarını düzeltme eklentisi
+Comment[uk]=Втулок противіньєткового ефекту зображень для digiKam
+Comment[vi]=Phần bổ sung hiệu ứng chống làm mờ nét ảnh cho digiKam
+Comment[xx]=xxAnti Vignetting image effect plugin for digiKamxx
+
+X-TDE-Library=digikamimageplugin_antivignetting
+author=Gilles Caulier, caulier dot gilles at gmail dot com
diff --git a/src/imageplugins/antivignetting/digikamimageplugin_antivignetting_ui.rc b/src/imageplugins/antivignetting/digikamimageplugin_antivignetting_ui.rc
new file mode 100644
index 00000000..7a54a1f3
--- /dev/null
+++ b/src/imageplugins/antivignetting/digikamimageplugin_antivignetting_ui.rc
@@ -0,0 +1,20 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui version="5" name="digikamimageplugin_antivignetting" >
+
+ <MenuBar>
+
+ <Menu name="Enhance" ><text>Enh&amp;ance</text>
+ <Action name="imageplugin_antivignetting" />
+ </Menu>
+
+ </MenuBar>
+
+ <ToolBar name="ToolBar" >
+ <text>Main Toolbar</text>
+ </ToolBar>
+
+ <ActionProperties>
+ <Action name="imageplugin_antivignetting" />
+ </ActionProperties>
+
+</kpartgui>
diff --git a/src/imageplugins/antivignetting/imageeffect_antivignetting.cpp b/src/imageplugins/antivignetting/imageeffect_antivignetting.cpp
new file mode 100644
index 00000000..7d7a00c6
--- /dev/null
+++ b/src/imageplugins/antivignetting/imageeffect_antivignetting.cpp
@@ -0,0 +1,380 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2004-12-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqlabel.h>
+#include <tqwhatsthis.h>
+#include <tqlayout.h>
+#include <tqimage.h>
+#include <tqpixmap.h>
+#include <tqpainter.h>
+#include <tqpen.h>
+#include <tqtabwidget.h>
+
+// KDE includes.
+
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdeaboutdata.h>
+#include <kiconloader.h>
+#include <tdeapplication.h>
+#include <kstandarddirs.h>
+#include <knuminput.h>
+#include <kseparator.h>
+
+// Local includes.
+
+#include "version.h"
+#include "ddebug.h"
+#include "bcgmodifier.h"
+#include "imageiface.h"
+#include "imagewidget.h"
+#include "dimgimagefilters.h"
+#include "antivignetting.h"
+#include "imageeffect_antivignetting.h"
+#include "imageeffect_antivignetting.moc"
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+ImageEffect_AntiVignetting::ImageEffect_AntiVignetting(TQWidget* parent)
+ : Digikam::ImageGuideDlg(parent, i18n("Vignetting Correction"),
+ "antivignettings", false, true, false,
+ Digikam::ImageGuideWidget::HVGuideMode, 0, true)
+{
+ TQString whatsThis;
+
+ TDEAboutData* about = new TDEAboutData("digikam",
+ I18N_NOOP("Vignetting Correction"),
+ digikam_version,
+ I18N_NOOP("A digiKam image plugin to reduce image vignetting."),
+ TDEAboutData::License_GPL,
+ "(c) 2004-2008, Gilles Caulier",
+ 0,
+ "http://www.digikam.org");
+
+ about->addAuthor("Gilles Caulier", I18N_NOOP("Author and maintainer"),
+ "caulier dot gilles at gmail dot com");
+
+ about->addAuthor("John Walker", I18N_NOOP("Anti Vignetting algorithm"), 0,
+ "http://www.fourmilab.ch/netpbm/pnmctrfilt");
+
+ setAboutData(about);
+
+ // -------------------------------------------------------------
+
+ TQWidget *gboxSettings = new TQWidget(plainPage());
+ TQGridLayout* gridSettings = new TQGridLayout( gboxSettings, 13, 2, spacingHint());
+
+ m_maskPreviewLabel = new TQLabel( gboxSettings );
+ m_maskPreviewLabel->setAlignment ( TQt::AlignHCenter | TQt::AlignVCenter );
+ TQWhatsThis::add( m_maskPreviewLabel, i18n("<p>You can see here a thumbnail preview of the anti-vignetting "
+ "mask applied to the image.") );
+ gridSettings->addMultiCellWidget(m_maskPreviewLabel, 0, 0, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label1 = new TQLabel(i18n("Density:"), gboxSettings);
+
+ m_densityInput = new KDoubleNumInput(gboxSettings);
+ m_densityInput->setPrecision(1);
+ m_densityInput->setRange(1.0, 20.0, 0.1, true);
+ TQWhatsThis::add( m_densityInput, i18n("<p>This value controls the degree of intensity attenuation by the filter "
+ "at its point of maximum density."));
+
+ gridSettings->addMultiCellWidget(label1, 1, 1, 0, 2);
+ gridSettings->addMultiCellWidget(m_densityInput, 2, 2, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label2 = new TQLabel(i18n("Power:"), gboxSettings);
+
+ m_powerInput = new KDoubleNumInput(gboxSettings);
+ m_powerInput->setPrecision(1);
+ m_powerInput->setRange(0.1, 2.0, 0.1, true);
+ TQWhatsThis::add( m_powerInput, i18n("<p>This value is used as the exponent controlling the fall-off in density "
+ "from the center of the filter to the periphery."));
+
+ gridSettings->addMultiCellWidget(label2, 3, 3, 0, 2);
+ gridSettings->addMultiCellWidget(m_powerInput, 4, 4, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label3 = new TQLabel(i18n("Radius:"), gboxSettings);
+
+ m_radiusInput = new KDoubleNumInput(gboxSettings);
+ m_radiusInput->setPrecision(1);
+ m_radiusInput->setRange(-100.0, 100.0, 0.1, true);
+ TQWhatsThis::add( m_radiusInput, i18n("<p>This value is the radius of the center filter. It is a multiple of the "
+ "half-diagonal measure of the image, at which the density of the filter falls "
+ "to zero."));
+
+ gridSettings->addMultiCellWidget(label3, 5, 5, 0, 2);
+ gridSettings->addMultiCellWidget(m_radiusInput, 6, 6, 0, 2);
+
+ KSeparator *line = new KSeparator(Horizontal, gboxSettings);
+ gridSettings->addMultiCellWidget(line, 7, 7, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label4 = new TQLabel(i18n("Brightness:"), gboxSettings);
+
+ m_brightnessInput = new KIntNumInput(gboxSettings);
+ m_brightnessInput->setRange(0, 100, 1, true);
+ TQWhatsThis::add( m_brightnessInput, i18n("<p>Set here the brightness re-adjustment of the target image."));
+
+ gridSettings->addMultiCellWidget(label4, 8, 8, 0, 2);
+ gridSettings->addMultiCellWidget(m_brightnessInput, 9, 9, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label5 = new TQLabel(i18n("Contrast:"), gboxSettings);
+
+ m_contrastInput = new KIntNumInput(gboxSettings);
+ m_contrastInput->setRange(0, 100, 1, true);
+ TQWhatsThis::add( m_contrastInput, i18n("<p>Set here the contrast re-adjustment of the target image."));
+
+ gridSettings->addMultiCellWidget(label5, 10, 10, 0, 2);
+ gridSettings->addMultiCellWidget(m_contrastInput, 11, 11, 0, 2);
+
+ // -------------------------------------------------------------
+
+ TQLabel *label6 = new TQLabel(i18n("Gamma:"), gboxSettings);
+
+ m_gammaInput = new KDoubleNumInput(gboxSettings);
+ m_gammaInput->setPrecision(2);
+ m_gammaInput->setRange(0.1, 3.0, 0.01, true);
+ m_gammaInput->setValue(1.0);
+ TQWhatsThis::add( m_gammaInput, i18n("<p>Set here the gamma re-adjustment of the target image."));
+
+ gridSettings->addMultiCellWidget(label6, 12, 12, 0, 2);
+ gridSettings->addMultiCellWidget(m_gammaInput, 13, 13, 0, 2);
+
+ setUserAreaWidget(gboxSettings);
+
+ // -------------------------------------------------------------
+
+ connect(m_densityInput, TQ_SIGNAL(valueChanged (double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_powerInput, TQ_SIGNAL(valueChanged (double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_radiusInput, TQ_SIGNAL(valueChanged (double)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_brightnessInput, TQ_SIGNAL(valueChanged (int)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_contrastInput, TQ_SIGNAL(valueChanged (int)),
+ this, TQ_SLOT(slotTimer()));
+
+ connect(m_gammaInput, TQ_SIGNAL(valueChanged (double)),
+ this, TQ_SLOT(slotTimer()));
+}
+
+ImageEffect_AntiVignetting::~ImageEffect_AntiVignetting()
+{
+}
+
+void ImageEffect_AntiVignetting::renderingFinished()
+{
+ m_densityInput->setEnabled(true);
+ m_powerInput->setEnabled(true);
+ m_radiusInput->setEnabled(true);
+ m_brightnessInput->setEnabled(true);
+ m_contrastInput->setEnabled(true);
+ m_gammaInput->setEnabled(true);
+}
+
+void ImageEffect_AntiVignetting::readUserSettings()
+{
+ TDEConfig* config = kapp->config();
+ config->setGroup("antivignettings Tool Dialog");
+
+ m_densityInput->blockSignals(true);
+ m_powerInput->blockSignals(true);
+ m_radiusInput->blockSignals(true);
+ m_brightnessInput->blockSignals(true);
+ m_contrastInput->blockSignals(true);
+ m_gammaInput->blockSignals(true);
+
+ m_densityInput->setValue(config->readDoubleNumEntry("DensityAjustment", 2.0));
+ m_powerInput->setValue(config->readDoubleNumEntry("PowerAjustment", 1.0));
+ m_radiusInput->setValue(config->readDoubleNumEntry("RadiusAjustment", 1.0));
+ m_brightnessInput->setValue(config->readNumEntry("BrightnessAjustment", 0));
+ m_contrastInput->setValue(config->readNumEntry("ContrastAjustment", 0));
+ m_gammaInput->setValue(config->readDoubleNumEntry("GammaAjustment", 1.0));
+
+ m_densityInput->blockSignals(false);
+ m_powerInput->blockSignals(false);
+ m_radiusInput->blockSignals(false);
+ m_brightnessInput->blockSignals(false);
+ m_contrastInput->blockSignals(false);
+ m_gammaInput->blockSignals(false);
+
+ slotEffect();
+}
+
+void ImageEffect_AntiVignetting::writeUserSettings()
+{
+ TDEConfig* config = kapp->config();
+ config->setGroup("antivignettings Tool Dialog");
+ config->writeEntry("DensityAjustment", m_densityInput->value());
+ config->writeEntry("PowerAjustment", m_powerInput->value());
+ config->writeEntry("RadiusAjustment", m_radiusInput->value());
+ config->writeEntry("BrightnessAjustment", m_brightnessInput->value());
+ config->writeEntry("ContrastAjustment", m_contrastInput->value());
+ config->writeEntry("GammaAjustment", m_gammaInput->value());
+ config->sync();
+}
+
+void ImageEffect_AntiVignetting::resetValues()
+{
+ m_densityInput->blockSignals(true);
+ m_powerInput->blockSignals(true);
+ m_radiusInput->blockSignals(true);
+ m_brightnessInput->blockSignals(true);
+ m_contrastInput->blockSignals(true);
+ m_gammaInput->blockSignals(true);
+
+ m_densityInput->setValue(2.0);
+ m_powerInput->setValue(1.0);
+ m_radiusInput->setValue(1.0);
+ m_brightnessInput->setValue(0);
+ m_contrastInput->setValue(0);
+ m_gammaInput->setValue(1.0);
+
+ m_densityInput->blockSignals(false);
+ m_powerInput->blockSignals(false);
+ m_radiusInput->blockSignals(false);
+ m_brightnessInput->blockSignals(false);
+ m_contrastInput->blockSignals(false);
+ m_gammaInput->blockSignals(false);
+}
+
+void ImageEffect_AntiVignetting::prepareEffect()
+{
+ m_densityInput->setEnabled(false);
+ m_powerInput->setEnabled(false);
+ m_radiusInput->setEnabled(false);
+ m_brightnessInput->setEnabled(false);
+ m_contrastInput->setEnabled(false);
+ m_gammaInput->setEnabled(false);
+
+ double d = m_densityInput->value();
+ double p = m_powerInput->value();
+ double r = m_radiusInput->value();
+
+ Digikam::ImageIface* iface = m_imagePreviewWidget->imageIface();
+ uchar *data = iface->getOriginalImage();
+ int orgWidth = iface->originalWidth();
+ int orgHeight = iface->originalHeight();
+ TQSize ps(orgWidth, orgHeight);
+ ps.scale( TQSize(120, 120), TQSize::ScaleMin );
+
+ // Calc mask preview.
+ Digikam::DImg preview(ps.width(), ps.height(), false);
+ memset(preview.bits(), 255, preview.numBytes());
+ AntiVignetting maskPreview(&preview, 0L, d, p, r, 0, 0, false);
+ TQPixmap pix = maskPreview.getTargetImage().convertToPixmap();
+ TQPainter pt(&pix);
+ pt.setPen( TQPen(TQt::black, 1) );
+ pt.drawRect( 0, 0, pix.width(), pix.height() );
+ pt.end();
+ m_maskPreviewLabel->setPixmap( pix );
+
+ Digikam::DImg orgImage(orgWidth, orgHeight, iface->originalSixteenBit(),
+ iface->originalHasAlpha(), data);
+ delete [] data;
+
+ m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>(
+ new AntiVignetting(&orgImage, this, d, p, r, 0, 0, true));
+}
+
+void ImageEffect_AntiVignetting::prepareFinal()
+{
+ m_densityInput->setEnabled(false);
+ m_powerInput->setEnabled(false);
+ m_radiusInput->setEnabled(false);
+ m_brightnessInput->setEnabled(false);
+ m_contrastInput->setEnabled(false);
+ m_gammaInput->setEnabled(false);
+
+ double d = m_densityInput->value();
+ double p = m_powerInput->value();
+ double r = m_radiusInput->value();
+
+ Digikam::ImageIface iface(0, 0);
+
+ uchar *data = iface.getOriginalImage();
+ Digikam::DImg orgImage(iface.originalWidth(), iface.originalHeight(), iface.originalSixteenBit(),
+ iface.originalHasAlpha(), data);
+ delete [] data;
+
+ m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>(
+ new AntiVignetting(&orgImage, this, d, p, r, 0, 0, true));
+}
+
+void ImageEffect_AntiVignetting::putPreviewData(void)
+{
+ Digikam::ImageIface* iface = m_imagePreviewWidget->imageIface();
+
+ Digikam::DImg imDest = m_threadedFilter->getTargetImage();
+
+ // Adjust Image BCG.
+
+ double b = (double)(m_brightnessInput->value() / 100.0);
+ double c = (double)(m_contrastInput->value() / 100.0) + (double)(1.00);
+ double g = m_gammaInput->value();
+
+ Digikam::BCGModifier cmod;
+ cmod.setGamma(g);
+ cmod.setBrightness(b);
+ cmod.setContrast(c);
+ cmod.applyBCG(imDest);
+
+ iface->putPreviewImage((imDest.smoothScale(iface->previewWidth(),
+ iface->previewHeight())).bits());
+ m_imagePreviewWidget->updatePreview();
+}
+
+void ImageEffect_AntiVignetting::putFinalData(void)
+{
+ Digikam::ImageIface iface(0, 0);
+
+ iface.putOriginalImage(i18n("Vignetting Correction"),
+ m_threadedFilter->getTargetImage().bits());
+
+ double b = (double)(m_brightnessInput->value() / 100.0);
+ double c = (double)(m_contrastInput->value() / 100.0) + (double)(1.00);
+ double g = m_gammaInput->value();
+
+ // Adjust Image BCG.
+ iface.setOriginalBCG(b, c, g);
+}
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
+
diff --git a/src/imageplugins/antivignetting/imageeffect_antivignetting.h b/src/imageplugins/antivignetting/imageeffect_antivignetting.h
new file mode 100644
index 00000000..3ee6f158
--- /dev/null
+++ b/src/imageplugins/antivignetting/imageeffect_antivignetting.h
@@ -0,0 +1,79 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2005-05-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+#ifndef IMAGEEFFECT_ANTIVIGNETTING_H
+#define IMAGEEFFECT_ANTIVIGNETTING_H
+
+// Digikam includes.
+
+#include "imageguidedlg.h"
+
+class TQLabel;
+
+class KIntNumInput;
+class KDoubleNumInput;
+
+namespace DigikamAntiVignettingImagesPlugin
+{
+
+class ImageEffect_AntiVignetting : public Digikam::ImageGuideDlg
+{
+ TQ_OBJECT
+
+
+public:
+
+ ImageEffect_AntiVignetting(TQWidget *parent);
+ ~ImageEffect_AntiVignetting();
+
+private slots:
+
+ void readUserSettings();
+
+private:
+
+ void writeUserSettings();
+ void resetValues();
+ void prepareEffect();
+ void prepareFinal();
+ void putPreviewData();
+ void putFinalData();
+ void renderingFinished();
+
+private:
+
+ TQLabel *m_maskPreviewLabel;
+
+ KIntNumInput *m_brightnessInput;
+ KIntNumInput *m_contrastInput;
+
+ KDoubleNumInput *m_gammaInput;
+ KDoubleNumInput *m_densityInput;
+ KDoubleNumInput *m_powerInput;
+ KDoubleNumInput *m_radiusInput;
+};
+
+} // NameSpace DigikamAntiVignettingImagesPlugin
+
+#endif /* IMAGEEFFECT_ANTIVIGNETTING_H */
diff --git a/src/imageplugins/antivignetting/imageplugin_antivignetting.cpp b/src/imageplugins/antivignetting/imageplugin_antivignetting.cpp
new file mode 100644
index 00000000..239d9842
--- /dev/null
+++ b/src/imageplugins/antivignetting/imageplugin_antivignetting.cpp
@@ -0,0 +1,70 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2004-12-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+// KDE includes.
+
+#include <tdelocale.h>
+#include <kgenericfactory.h>
+#include <klibloader.h>
+#include <tdeaction.h>
+#include <kcursor.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "antivignettingtool.h"
+#include "imageplugin_antivignetting.h"
+#include "imageplugin_antivignetting.moc"
+
+using namespace DigikamAntiVignettingImagesPlugin;
+
+K_EXPORT_COMPONENT_FACTORY(digikamimageplugin_antivignetting,
+ KGenericFactory<ImagePlugin_AntiVignetting>("digikamimageplugin_antivignetting"));
+
+ImagePlugin_AntiVignetting::ImagePlugin_AntiVignetting(TQObject *parent, const char*, const TQStringList &)
+ : Digikam::ImagePlugin(parent, "ImagePlugin_AntiVignetting")
+{
+ m_antivignettingAction = new TDEAction(i18n("Vignetting Correction..."), "antivignetting", 0,
+ this, TQ_SLOT(slotAntiVignetting()),
+ actionCollection(), "imageplugin_antivignetting");
+
+ setXMLFile("digikamimageplugin_antivignetting_ui.rc");
+
+ DDebug() << "ImagePlugin_AntiVignetting plugin loaded" << endl;
+}
+
+ImagePlugin_AntiVignetting::~ImagePlugin_AntiVignetting()
+{
+}
+
+void ImagePlugin_AntiVignetting::setEnabledActions(bool enable)
+{
+ m_antivignettingAction->setEnabled(enable);
+}
+
+void ImagePlugin_AntiVignetting::slotAntiVignetting()
+{
+ AntiVignettingTool *tool = new AntiVignettingTool(this);
+ loadTool(tool);
+}
diff --git a/src/imageplugins/antivignetting/imageplugin_antivignetting.h b/src/imageplugins/antivignetting/imageplugin_antivignetting.h
new file mode 100644
index 00000000..d8d4eedd
--- /dev/null
+++ b/src/imageplugins/antivignetting/imageplugin_antivignetting.h
@@ -0,0 +1,57 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2004-12-25
+ * Description : a digiKam image plugin to reduce
+ * vignetting on an image.
+ *
+ * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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.
+ *
+ * ============================================================ */
+
+#ifndef IMAGEPLUGIN_ANTIVIGNETTING_H
+#define IMAGEPLUGIN_ANTIVIGNETTING_H
+
+// Digikam includes.
+
+#include "imageplugin.h"
+#include "digikam_export.h"
+
+class TDEAction;
+
+class DIGIKAMIMAGEPLUGINS_EXPORT ImagePlugin_AntiVignetting : public Digikam::ImagePlugin
+{
+ TQ_OBJECT
+
+
+public:
+
+ ImagePlugin_AntiVignetting(TQObject *parent, const char* name,
+ const TQStringList &args);
+ ~ImagePlugin_AntiVignetting();
+
+ void setEnabledActions(bool enable);
+
+private slots:
+
+ void slotAntiVignetting();
+
+private:
+
+ TDEAction *m_antivignettingAction;
+};
+
+#endif /* IMAGEPLUGIN_ANTIVIGNETTING_H */