diff options
author | Michele Calgaro <[email protected]> | 2024-11-22 18:41:30 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-11-22 18:41:30 +0900 |
commit | ee0d99607c14cb63d3ebdb3a970b508949fa8219 (patch) | |
tree | 94ac1efedb94cb38bf6879ba0610fe75b554216b /src/imageplugins/adjustcurves | |
parent | 4adff739380e4ae9f30e443ee95644f184456869 (diff) | |
download | digikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.tar.gz digikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.zip |
Rename 'digikam' folder to 'src'
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src/imageplugins/adjustcurves')
-rw-r--r-- | src/imageplugins/adjustcurves/Makefile.am | 33 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/adjustcurves.cpp | 677 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/adjustcurves.h | 143 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/adjustcurvestool.cpp | 659 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/adjustcurvestool.h | 145 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves.desktop | 52 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves_ui.rc | 20 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/imageplugin_adjustcurves.cpp | 70 | ||||
-rw-r--r-- | src/imageplugins/adjustcurves/imageplugin_adjustcurves.h | 56 |
9 files changed, 1855 insertions, 0 deletions
diff --git a/src/imageplugins/adjustcurves/Makefile.am b/src/imageplugins/adjustcurves/Makefile.am new file mode 100644 index 00000000..f798a7af --- /dev/null +++ b/src/imageplugins/adjustcurves/Makefile.am @@ -0,0 +1,33 @@ +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_adjustcurves_la_SOURCES = imageplugin_adjustcurves.cpp \ + adjustcurvestool.cpp + +digikamimageplugin_adjustcurves_la_LIBADD = $(LIB_TDEPARTS) \ + $(top_builddir)/src/digikam/libdigikam.la + +digikamimageplugin_adjustcurves_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -ltdecore -ltdeui $(LIB_TQT) -ltdefx -lkdcraw -ltdeio + +kde_services_DATA = digikamimageplugin_adjustcurves.desktop + +kde_module_LTLIBRARIES = digikamimageplugin_adjustcurves.la + +rcdir = $(kde_datadir)/digikam +rc_DATA = digikamimageplugin_adjustcurves_ui.rc diff --git a/src/imageplugins/adjustcurves/adjustcurves.cpp b/src/imageplugins/adjustcurves/adjustcurves.cpp new file mode 100644 index 00000000..ace9c9b3 --- /dev/null +++ b/src/imageplugins/adjustcurves/adjustcurves.cpp @@ -0,0 +1,677 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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. + * + * ============================================================ */ + +// C++ includes. + +#include <cmath> + +// TQt includes. + +#include <tqlayout.h> +#include <tqcolor.h> +#include <tqgroupbox.h> +#include <tqhgroupbox.h> +#include <tqvgroupbox.h> +#include <tqlabel.h> +#include <tqpainter.h> +#include <tqcombobox.h> +#include <tqspinbox.h> +#include <tqwhatsthis.h> +#include <tqtooltip.h> +#include <tqpushbutton.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqtimer.h> +#include <tqhbuttongroup.h> +#include <tqpixmap.h> + +// KDE includes. + +#include <tdeconfig.h> +#include <kcursor.h> +#include <tdelocale.h> +#include <knuminput.h> +#include <tdemessagebox.h> +#include <tdeselect.h> +#include <tdefiledialog.h> +#include <tdeglobalsettings.h> +#include <tdeaboutdata.h> +#include <khelpmenu.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdepopupmenu.h> +#include <kstandarddirs.h> + +// Local includes. + +#include "version.h" +#include "ddebug.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "imagehistogram.h" +#include "imagecurves.h" +#include "histogramwidget.h" +#include "curveswidget.h" +#include "colorgradientwidget.h" +#include "dimgimagefilters.h" +#include "adjustcurves.h" +#include "adjustcurves.moc" + +namespace DigikamAdjustCurvesImagesPlugin +{ + +AdjustCurveDialog::AdjustCurveDialog(TQWidget* parent) + : Digikam::ImageDlgBase(parent, i18n("Adjust Color Curves"), "adjustcurves", true, false) +{ + m_destinationPreviewData = 0L; + + Digikam::ImageIface iface(0, 0); + uchar *data = iface.getOriginalImage(); + int w = iface.originalWidth(); + int h = iface.originalHeight(); + bool sixteenBit = iface.originalSixteenBit(); + bool hasAlpha = iface.originalHasAlpha(); + m_originalImage = Digikam::DImg(w, h, sixteenBit, hasAlpha ,data); + delete [] data; + + m_histoSegments = m_originalImage.sixteenBit() ? 65535 : 255; + m_curves = new Digikam::ImageCurves(m_originalImage.sixteenBit()); + + // About data and help button. + + TDEAboutData* about = new TDEAboutData("digikam", + I18N_NOOP("Adjust Color Curves"), + digikam_version, + I18N_NOOP("An image-histogram-curves adjustment plugin for digiKam."), + 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"); + + setAboutData(about); + + // ------------------------------------------------------------- + + m_previewWidget = new Digikam::ImageWidget("adjustcurves Tool Dialog", plainPage(), + i18n("<p>This is the image's curve-adjustments preview. " + "You can pick a spot on the image " + "to see the corresponding level in the histogram.")); + setPreviewAreaWidget(m_previewWidget); + + // ------------------------------------------------------------- + + TQWidget *gboxSettings = new TQWidget(plainPage()); + TQGridLayout* grid = new TQGridLayout( gboxSettings, 5, 5, spacingHint()); + + TQLabel *label1 = new TQLabel(i18n("Channel:"), gboxSettings); + label1->setAlignment ( TQt::AlignRight | TQt::AlignVCenter ); + m_channelCB = new TQComboBox( false, gboxSettings ); + m_channelCB->insertItem( i18n("Luminosity") ); + m_channelCB->insertItem( i18n("Red") ); + m_channelCB->insertItem( i18n("Green") ); + m_channelCB->insertItem( i18n("Blue") ); + m_channelCB->insertItem( i18n("Alpha") ); + m_channelCB->setCurrentText( i18n("Luminosity") ); + TQWhatsThis::add( m_channelCB, i18n("<p>Select the histogram channel to display here:<p>" + "<b>Luminosity</b>: display the image's luminosity values.<p>" + "<b>Red</b>: display the red image-channel values.<p>" + "<b>Green</b>: display the green image-channel values.<p>" + "<b>Blue</b>: display the blue image-channel values.<p>" + "<b>Alpha</b>: display the alpha image-channel values. " + "This channel corresponds to the transparency value and " + "is supported by some image formats, such as PNG or TIF.")); + + m_scaleBG = new TQHButtonGroup(gboxSettings); + TQWhatsThis::add( m_scaleBG, i18n("<p>Select the histogram scale here.<p>" + "If the image's maximal counts are small, you can use the linear scale.<p>" + "Logarithmic scale can be used when the maximal counts are big; " + "if it is used, all values (small and large) will be visible on the graph.")); + + TQPushButton *linHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( linHistoButton, i18n( "<p>Linear" ) ); + m_scaleBG->insert(linHistoButton, Digikam::CurvesWidget::LinScaleHistogram); + TDEGlobal::dirs()->addResourceType("histogram-lin", TDEGlobal::dirs()->kde_default("data") + "digikam/data"); + TQString directory = TDEGlobal::dirs()->findResourceDir("histogram-lin", "histogram-lin.png"); + linHistoButton->setPixmap( TQPixmap( directory + "histogram-lin.png" ) ); + linHistoButton->setToggleButton(true); + + TQPushButton *logHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( logHistoButton, i18n( "<p>Logarithmic" ) ); + m_scaleBG->insert(logHistoButton, Digikam::CurvesWidget::LogScaleHistogram); + TDEGlobal::dirs()->addResourceType("histogram-log", TDEGlobal::dirs()->kde_default("data") + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("histogram-log", "histogram-log.png"); + logHistoButton->setPixmap( TQPixmap( directory + "histogram-log.png" ) ); + logHistoButton->setToggleButton(true); + + m_scaleBG->setExclusive(true); + m_scaleBG->setButton(Digikam::CurvesWidget::LogScaleHistogram); + m_scaleBG->setFrameShape(TQFrame::NoFrame); + m_scaleBG->setInsideMargin( 0 ); + + TQHBoxLayout* l1 = new TQHBoxLayout(); + l1->addStretch(10); + l1->addWidget(m_scaleBG); + + grid->addMultiCellWidget(label1, 0, 0, 1, 1); + grid->addMultiCellWidget(m_channelCB, 0, 0, 2, 2); + grid->addMultiCellLayout(l1, 0, 0, 4, 5); + + // ------------------------------------------------------------- + + TQWidget *curveBox = new TQWidget(gboxSettings); + TQGridLayout* gl = new TQGridLayout(curveBox, 4, 2, 0); + + m_histogramWidget = new Digikam::HistogramWidget(256, 140, curveBox, false, true, true); + TQWhatsThis::add( m_histogramWidget, i18n("<p>Here you can see the target preview image histogram drawing " + "of the selected image channel. This one is re-computed at any " + "curves settings changes.")); + + m_vGradient = new Digikam::ColorGradientWidget( Digikam::ColorGradientWidget::Vertical, 10, curveBox ); + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + + TQLabel *spacev = new TQLabel(curveBox); + spacev->setFixedWidth(1); + + m_curvesWidget = new Digikam::CurvesWidget(256, 256, m_originalImage.bits(), m_originalImage.width(), + m_originalImage.height(), m_originalImage.sixteenBit(), + m_curves, curveBox); + TQWhatsThis::add( m_curvesWidget, i18n("<p>This is the curve drawing of the selected channel from " + "original image")); + + TQLabel *spaceh = new TQLabel(curveBox); + spaceh->setFixedHeight(1); + + m_hGradient = new Digikam::ColorGradientWidget( Digikam::ColorGradientWidget::Horizontal, 10, curveBox ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + + gl->addMultiCellWidget(m_histogramWidget, 0, 0, 2, 2); + gl->addMultiCellWidget(m_vGradient, 2, 2, 0, 0); + gl->addMultiCellWidget(spacev, 2, 2, 1, 1); + gl->addMultiCellWidget(m_curvesWidget, 2, 2, 2, 2); + gl->addMultiCellWidget(spaceh, 3, 3, 2, 2); + gl->addMultiCellWidget(m_hGradient, 4, 4, 2, 2); + gl->setRowSpacing(1, spacingHint()); + + grid->addMultiCellWidget(curveBox, 2, 3, 0, 5); + + // ------------------------------------------------------------- + + m_curveType = new TQHButtonGroup(gboxSettings); + m_curveFree = new TQPushButton(m_curveType); + m_curveType->insert(m_curveFree, FreeDrawing); + TDEGlobal::dirs()->addResourceType("curvefree", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("curvefree", "curvefree.png"); + m_curveFree->setPixmap( TQPixmap( directory + "curvefree.png" ) ); + m_curveFree->setToggleButton(true); + TQToolTip::add( m_curveFree, i18n( "Curve free mode" ) ); + TQWhatsThis::add( m_curveFree, i18n("<p>With this button, you can draw your curve free-hand with the mouse.")); + m_curveSmooth = new TQPushButton(m_curveType); + m_curveType->insert(m_curveSmooth, SmoothDrawing); + TDEGlobal::dirs()->addResourceType("curvemooth", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("curvemooth", "curvemooth.png"); + m_curveSmooth->setPixmap( TQPixmap( directory + "curvemooth.png" ) ); + m_curveSmooth->setToggleButton(true); + TQToolTip::add( m_curveSmooth, i18n( "Curve smooth mode" ) ); + TQWhatsThis::add( m_curveSmooth, i18n("<p>With this button, you constrains the curve type to a smooth line with tension.")); + m_curveType->setExclusive(true); + m_curveType->setButton(SmoothDrawing); + m_curveType->setFrameShape(TQFrame::NoFrame); + + // ------------------------------------------------------------- + + m_pickerColorButtonGroup = new TQHButtonGroup(gboxSettings); + m_pickBlack = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickBlack, BlackTonal); + TDEGlobal::dirs()->addResourceType("color-picker-black", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-black", "color-picker-black.png"); + m_pickBlack->setPixmap( TQPixmap( directory + "color-picker-black.png" ) ); + m_pickBlack->setToggleButton(true); + TQToolTip::add( m_pickBlack, i18n( "All channels shadow tone color picker" ) ); + TQWhatsThis::add( m_pickBlack, i18n("<p>With this button, you can pick the color from original image used to set <b>Shadow Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickGray = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickGray, GrayTonal); + TDEGlobal::dirs()->addResourceType("color-picker-grey", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-grey", "color-picker-grey.png"); + m_pickGray->setPixmap( TQPixmap( directory + "color-picker-grey.png" ) ); + m_pickGray->setToggleButton(true); + TQToolTip::add( m_pickGray, i18n( "All channels middle tone color picker" ) ); + TQWhatsThis::add( m_pickGray, i18n("<p>With this button, you can pick the color from original image used to set <b>Middle Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickWhite = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickWhite, WhiteTonal); + TDEGlobal::dirs()->addResourceType("color-picker-white", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-white", "color-picker-white.png"); + m_pickWhite->setPixmap( TQPixmap( directory + "color-picker-white.png" ) ); + m_pickWhite->setToggleButton(true); + TQToolTip::add( m_pickWhite, i18n( "All channels highlight tone color picker" ) ); + TQWhatsThis::add( m_pickWhite, i18n("<p>With this button, you can pick the color from original image used to set <b>Highlight Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickerColorButtonGroup->setExclusive(true); + m_pickerColorButtonGroup->setFrameShape(TQFrame::NoFrame); + + // ------------------------------------------------------------- + + m_resetButton = new TQPushButton(i18n("&Reset"), gboxSettings); + m_resetButton->setPixmap( SmallIcon("reload_page", 18) ); + TQToolTip::add( m_resetButton, i18n( "Reset current channel curves' values." ) ); + TQWhatsThis::add( m_resetButton, i18n("<p>If you press this button, all curves' values " + "from the current selected channel " + "will be reset to the default values.")); + + TQHBoxLayout* l3 = new TQHBoxLayout(); + l3->addWidget(m_curveType); + l3->addWidget(m_pickerColorButtonGroup); + l3->addWidget(m_resetButton); + l3->addStretch(10); + + grid->addMultiCellLayout(l3, 4, 4, 1, 5); + + // ------------------------------------------------------------- + + + grid->setRowStretch(5, 10); + setUserAreaWidget(gboxSettings); + + // ------------------------------------------------------------- + + connect(m_curvesWidget, TQ_SIGNAL(signalCurvesChanged()), + this, TQ_SLOT(slotTimer())); + + connect(m_previewWidget, TQ_SIGNAL(spotPositionChangedFromOriginal( const Digikam::DColor &, const TQPoint & )), + this, TQ_SLOT(slotSpotColorChanged( const Digikam::DColor & ))); + + connect(m_previewWidget, TQ_SIGNAL(spotPositionChangedFromTarget( const Digikam::DColor &, const TQPoint & )), + this, TQ_SLOT(slotColorSelectedFromTarget( const Digikam::DColor & ))); + + connect(m_previewWidget, TQ_SIGNAL(signalResized()), + this, TQ_SLOT(slotEffect())); + + // ------------------------------------------------------------- + // ComboBox slots. + + connect(m_channelCB, TQ_SIGNAL(activated(int)), + this, TQ_SLOT(slotChannelChanged(int))); + + connect(m_scaleBG, TQ_SIGNAL(released(int)), + this, TQ_SLOT(slotScaleChanged(int))); + + connect(m_curveType, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(slotCurveTypeChanged(int))); + + // ------------------------------------------------------------- + // Bouttons slots. + + connect(m_resetButton, TQ_SIGNAL(clicked()), + this, TQ_SLOT(slotResetCurrentChannel())); + + connect(m_pickerColorButtonGroup, TQ_SIGNAL(released(int)), + this, TQ_SLOT(slotPickerColorButtonActived())); +} + +AdjustCurveDialog::~AdjustCurveDialog() +{ + m_histogramWidget->stopHistogramComputation(); + + if (m_destinationPreviewData) + delete [] m_destinationPreviewData; + + delete m_histogramWidget; + delete m_curvesWidget; + delete m_previewWidget; + delete m_curves; +} + +void AdjustCurveDialog::slotPickerColorButtonActived() +{ + // Save previous rendering mode and toggle to original image. + m_currentPreviewMode = m_previewWidget->getRenderingPreviewMode(); + m_previewWidget->setRenderingPreviewMode(Digikam::ImageGuideWidget::PreviewOriginalImage); +} + +void AdjustCurveDialog::slotSpotColorChanged(const Digikam::DColor &color) +{ + Digikam::DColor sc = color; + + if ( m_pickBlack->isOn() ) + { + // Black tonal curves point. + m_curves->setCurvePoint(Digikam::ImageHistogram::ValueChannel, 1, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 42*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::RedChannel, 1, TQPoint(sc.red(), 42*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::GreenChannel, 1, TQPoint(sc.green(), 42*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::BlueChannel, 1, TQPoint(sc.blue(), 42*m_histoSegments/256)); + m_pickBlack->setOn(false); + } + else if ( m_pickGray->isOn() ) + { + // Gray tonal curves point. + m_curves->setCurvePoint(Digikam::ImageHistogram::ValueChannel, 8, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 128*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::RedChannel, 8, TQPoint(sc.red(), 128*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::GreenChannel, 8, TQPoint(sc.green(), 128*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::BlueChannel, 8, TQPoint(sc.blue(), 128*m_histoSegments/256)); + m_pickGray->setOn(false); + } + else if ( m_pickWhite->isOn() ) + { + // White tonal curves point. + m_curves->setCurvePoint(Digikam::ImageHistogram::ValueChannel, 15, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 213*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::RedChannel, 15, TQPoint(sc.red(), 213*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::GreenChannel, 15, TQPoint(sc.green(), 213*m_histoSegments/256)); + m_curves->setCurvePoint(Digikam::ImageHistogram::BlueChannel, 15, TQPoint(sc.blue(), 213*m_histoSegments/256)); + m_pickWhite->setOn(false); + } + else + { + m_curvesWidget->setCurveGuide(color); + return; + } + + // Calculate Red, green, blue curves. + + for (int i = Digikam::ImageHistogram::ValueChannel ; i <= Digikam::ImageHistogram::BlueChannel ; i++) + m_curves->curvesCalculateCurve(i); + + m_curvesWidget->repaint(false); + + // restore previous rendering mode. + m_previewWidget->setRenderingPreviewMode(m_currentPreviewMode); + + slotEffect(); +} + +void AdjustCurveDialog::slotColorSelectedFromTarget( const Digikam::DColor &color ) +{ + m_histogramWidget->setHistogramGuideByColor(color); +} + +void AdjustCurveDialog::slotResetCurrentChannel() +{ + m_curves->curvesChannelReset(m_channelCB->currentItem()); + + m_curvesWidget->reset(); + slotEffect(); + m_histogramWidget->reset(); +} + +void AdjustCurveDialog::slotEffect() +{ + Digikam::ImageIface* iface = m_previewWidget->imageIface(); + uchar *orgData = iface->getPreviewImage(); + int w = iface->previewWidth(); + int h = iface->previewHeight(); + bool sb = iface->previewSixteenBit(); + + // Create the new empty destination image data space. + m_histogramWidget->stopHistogramComputation(); + + if (m_destinationPreviewData) + delete [] m_destinationPreviewData; + + m_destinationPreviewData = new uchar[w*h*(sb ? 8 : 4)]; + + // Calculate the LUT to apply on the image. + m_curves->curvesLutSetup(Digikam::ImageHistogram::AlphaChannel); + + // Apply the lut to the image. + m_curves->curvesLutProcess(orgData, m_destinationPreviewData, w, h); + + iface->putPreviewImage(m_destinationPreviewData); + m_previewWidget->updatePreview(); + + // Update histogram. + m_histogramWidget->updateData(m_destinationPreviewData, w, h, sb, 0, 0, 0, false); + delete [] orgData; +} + +void AdjustCurveDialog::finalRendering() +{ + kapp->setOverrideCursor( KCursor::waitCursor() ); + Digikam::ImageIface* iface = m_previewWidget->imageIface(); + uchar *orgData = iface->getOriginalImage(); + int w = iface->originalWidth(); + int h = iface->originalHeight(); + bool sb = iface->originalSixteenBit(); + + // Create the new empty destination image data space. + uchar* desData = new uchar[w*h*(sb ? 8 : 4)]; + + // Calculate the LUT to apply on the image. + m_curves->curvesLutSetup(Digikam::ImageHistogram::AlphaChannel); + + // Apply the lut to the image. + m_curves->curvesLutProcess(orgData, desData, w, h); + + iface->putOriginalImage(i18n("Adjust Curve"), desData); + kapp->restoreOverrideCursor(); + + delete [] orgData; + delete [] desData; + accept(); +} + +void AdjustCurveDialog::slotChannelChanged(int channel) +{ + switch(channel) + { + case LuminosityChannel: + m_histogramWidget->m_channelType = Digikam::HistogramWidget::ValueHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + m_curvesWidget->m_channelType = Digikam::CurvesWidget::ValueHistogram; + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + break; + + case RedChannel: + m_histogramWidget->m_channelType = Digikam::HistogramWidget::RedChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "red" ) ); + m_curvesWidget->m_channelType = Digikam::CurvesWidget::RedChannelHistogram; + m_vGradient->setColors( TQColor( "red" ), TQColor( "black" ) ); + break; + + case GreenChannel: + m_histogramWidget->m_channelType = Digikam::HistogramWidget::GreenChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "green" ) ); + m_curvesWidget->m_channelType = Digikam::CurvesWidget::GreenChannelHistogram; + m_vGradient->setColors( TQColor( "green" ), TQColor( "black" ) ); + break; + + case BlueChannel: + m_histogramWidget->m_channelType = Digikam::HistogramWidget::BlueChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "blue" ) ); + m_curvesWidget->m_channelType = Digikam::CurvesWidget::BlueChannelHistogram; + m_vGradient->setColors( TQColor( "blue" ), TQColor( "black" ) ); + break; + + case AlphaChannel: + m_histogramWidget->m_channelType = Digikam::HistogramWidget::AlphaChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + m_curvesWidget->m_channelType = Digikam::CurvesWidget::AlphaChannelHistogram; + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + break; + } + + m_curveType->setButton(m_curves->getCurveType(channel)); + + m_curvesWidget->repaint(false); + m_histogramWidget->repaint(false); +} + +void AdjustCurveDialog::slotScaleChanged(int scale) +{ + m_curvesWidget->m_scaleType = scale; + m_histogramWidget->m_scaleType = scale; + m_histogramWidget->repaint(false); + m_curvesWidget->repaint(false); +} + +void AdjustCurveDialog::slotCurveTypeChanged(int type) +{ + switch(type) + { + case SmoothDrawing: + { + m_curves->setCurveType(m_curvesWidget->m_channelType, Digikam::ImageCurves::CURVE_SMOOTH); + m_pickerColorButtonGroup->setEnabled(true); + break; + } + + case FreeDrawing: + { + m_curves->setCurveType(m_curvesWidget->m_channelType, Digikam::ImageCurves::CURVE_FREE); + m_pickerColorButtonGroup->setEnabled(false); + break; + } + } + + m_curvesWidget->curveTypeChanged(); +} + +void AdjustCurveDialog::readUserSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("adjustcurves Tool Dialog"); + + m_channelCB->setCurrentItem(config->readNumEntry("Histogram Channel", 0)); // Luminosity. + m_scaleBG->setButton(config->readNumEntry("Histogram Scale", Digikam::HistogramWidget::LogScaleHistogram)); + + m_curvesWidget->reset(); + + for (int i = 0 ; i < 5 ; i++) + { + m_curves->curvesChannelReset(i); + m_curves->setCurveType(i, (Digikam::ImageCurves::CurveType)config->readNumEntry(TQString("CurveTypeChannel%1").arg(i), + Digikam::ImageCurves::CURVE_SMOOTH)); + + for (int j = 0 ; j < 17 ; j++) + { + TQPoint disable(-1, -1); + TQPoint p = config->readPointEntry(TQString("CurveAjustmentChannel%1Point%2").arg(i).arg(j), &disable); + + if (m_originalImage.sixteenBit() && p.x() != -1) + { + p.setX(p.x()*255); + p.setY(p.y()*255); + } + + m_curves->setCurvePoint(i, j, p); + } + + m_curves->curvesCalculateCurve(i); + } + + slotChannelChanged(m_channelCB->currentItem()); + slotScaleChanged(m_scaleBG->selectedId()); +} + +void AdjustCurveDialog::writeUserSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("adjustcurves Tool Dialog"); + config->writeEntry("Histogram Channel", m_channelCB->currentItem()); + config->writeEntry("Histogram Scale", m_scaleBG->selectedId()); + + for (int i = 0 ; i < 5 ; i++) + { + config->writeEntry(TQString("CurveTypeChannel%1").arg(i), m_curves->getCurveType(i)); + + for (int j = 0 ; j < 17 ; j++) + { + TQPoint p = m_curves->getCurvePoint(i, j); + + if (m_originalImage.sixteenBit() && p.x() != -1) + { + p.setX(p.x()/255); + p.setY(p.y()/255); + } + + config->writeEntry(TQString("CurveAjustmentChannel%1Point%2").arg(i).arg(j), p); + } + } + + config->sync(); +} + +void AdjustCurveDialog::resetValues() +{ + for (int channel = 0 ; channel < 5 ; channel++) + m_curves->curvesChannelReset(channel); + + m_curvesWidget->reset(); + m_histogramWidget->reset(); +} + +// Load all settings. +void AdjustCurveDialog::slotUser3() +{ + KURL loadCurvesFile; + + loadCurvesFile = KFileDialog::getOpenURL(TDEGlobalSettings::documentPath(), + TQString( "*" ), this, + TQString( i18n("Select Gimp Curves File to Load")) ); + if( loadCurvesFile.isEmpty() ) + return; + + if ( m_curves->loadCurvesFromGimpCurvesFile( loadCurvesFile ) == false ) + { + KMessageBox::error(this, i18n("Cannot load from the Gimp curves text file.")); + return; + } + + // Refresh the current curves config. + slotChannelChanged(m_channelCB->currentItem()); + slotEffect(); +} + +// Save all settings. +void AdjustCurveDialog::slotUser2() +{ + KURL saveCurvesFile; + + saveCurvesFile = KFileDialog::getSaveURL(TDEGlobalSettings::documentPath(), + TQString( "*" ), this, + TQString( i18n("Gimp Curves File to Save")) ); + if( saveCurvesFile.isEmpty() ) + return; + + if ( m_curves->saveCurvesToGimpCurvesFile( saveCurvesFile ) == false ) + { + KMessageBox::error(this, i18n("Cannot save to the Gimp curves text file.")); + return; + } + + // Refresh the current curves config. + slotChannelChanged(m_channelCB->currentItem()); +} + +} // NameSpace DigikamAdjustCurvesImagesPlugin + diff --git a/src/imageplugins/adjustcurves/adjustcurves.h b/src/imageplugins/adjustcurves/adjustcurves.h new file mode 100644 index 00000000..f4cad2f2 --- /dev/null +++ b/src/imageplugins/adjustcurves/adjustcurves.h @@ -0,0 +1,143 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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 ADJUSTCURVES_H +#define ADJUSTCURVES_H + +// Digikam includes. + +#include "imagedlgbase.h" +#include "dimg.h" + +// Local includes. + +class TQComboBox; +class TQPushButton; +class TQHButtonGroup; + +namespace Digikam +{ +class CurvesWidget; +class HistogramWidget; +class ColorGradientWidget; +class ImageWidget; +class ImageCurves; +} + +namespace DigikamAdjustCurvesImagesPlugin +{ + +class AdjustCurveDialog : public Digikam::ImageDlgBase +{ + TQ_OBJECT + + +public: + + AdjustCurveDialog(TQWidget *parent); + ~AdjustCurveDialog(); + +private: + + void readUserSettings(); + void writeUserSettings(); + void resetValues(); + void finalRendering(); + +private slots: + + void slotUser2(); + void slotUser3(); + void slotEffect(); + void slotResetCurrentChannel(); + void slotChannelChanged(int channel); + void slotScaleChanged(int scale); + void slotCurveTypeChanged(int type); + void slotSpotColorChanged(const Digikam::DColor &color); + void slotColorSelectedFromTarget(const Digikam::DColor &color); + void slotPickerColorButtonActived(); + +private: + + enum ColorPicker + { + BlackTonal=0, + GrayTonal, + WhiteTonal + }; + + enum ColorChannel + { + LuminosityChannel=0, + RedChannel, + GreenChannel, + BlueChannel, + AlphaChannel + }; + + enum CurvesDrawingType + { + SmoothDrawing=0, + FreeDrawing + }; + + enum HistogramScale + { + Linear=0, + Logarithmic + }; + + uchar *m_destinationPreviewData; + + int m_histoSegments; + int m_currentPreviewMode; + + TQComboBox *m_channelCB; + + TQPushButton *m_resetButton; + TQPushButton *m_pickBlack; + TQPushButton *m_pickGray; + TQPushButton *m_pickWhite; + TQPushButton *m_curveFree; + TQPushButton *m_curveSmooth; + + TQHButtonGroup *m_pickerColorButtonGroup; + TQHButtonGroup *m_scaleBG; + TQHButtonGroup *m_curveType; + + Digikam::CurvesWidget *m_curvesWidget; + + Digikam::HistogramWidget *m_histogramWidget; + + Digikam::ColorGradientWidget *m_hGradient; + Digikam::ColorGradientWidget *m_vGradient; + + Digikam::ImageWidget *m_previewWidget; + + Digikam::ImageCurves *m_curves; + Digikam::DImg m_originalImage; +}; + +} // NameSpace DigikamAdjustCurvesImagesPlugin + +#endif /* ADJUSTCURVES_H */ diff --git a/src/imageplugins/adjustcurves/adjustcurvestool.cpp b/src/imageplugins/adjustcurves/adjustcurvestool.cpp new file mode 100644 index 00000000..7bfd00f7 --- /dev/null +++ b/src/imageplugins/adjustcurves/adjustcurvestool.cpp @@ -0,0 +1,659 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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. + * + * ============================================================ */ + +// C++ includes. + +#include <cmath> + +// TQt includes. + +#include <tqlayout.h> +#include <tqcolor.h> +#include <tqgroupbox.h> +#include <tqhgroupbox.h> +#include <tqvgroupbox.h> +#include <tqlabel.h> +#include <tqpainter.h> +#include <tqcombobox.h> +#include <tqspinbox.h> +#include <tqwhatsthis.h> +#include <tqtooltip.h> +#include <tqpushbutton.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqtimer.h> +#include <tqhbuttongroup.h> +#include <tqpixmap.h> + +// KDE includes. + +#include <tdeconfig.h> +#include <kcursor.h> +#include <tdelocale.h> +#include <knuminput.h> +#include <tdemessagebox.h> +#include <tdeselect.h> +#include <tdefiledialog.h> +#include <tdeglobalsettings.h> +#include <tdeaboutdata.h> +#include <khelpmenu.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <tdepopupmenu.h> +#include <kstandarddirs.h> +#include <kpushbutton.h> + +// Local includes. + +#include "daboutdata.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "imagehistogram.h" +#include "imagecurves.h" +#include "editortoolsettings.h" +#include "histogramwidget.h" +#include "curveswidget.h" +#include "colorgradientwidget.h" +#include "dimgimagefilters.h" +#include "adjustcurvestool.h" +#include "adjustcurvestool.moc" + +using namespace Digikam; + +namespace DigikamAdjustCurvesImagesPlugin +{ + +AdjustCurvesTool::AdjustCurvesTool(TQObject* parent) + : EditorTool(parent) +{ + m_destinationPreviewData = 0; + + ImageIface iface(0, 0); + m_originalImage = iface.getOriginalImg(); + + m_histoSegments = m_originalImage->sixteenBit() ? 65535 : 255; + + setName("adjustcurves"); + setToolName(i18n("Adjust Curves")); + setToolIcon(SmallIcon("adjustcurves")); + + // ------------------------------------------------------------- + + m_previewWidget = new ImageWidget("adjustcurves Tool", 0, + i18n("<p>This is the image's curve-adjustments preview. " + "You can pick a spot on the image " + "to see the corresponding level in the histogram.")); + setToolView(m_previewWidget); + + // ------------------------------------------------------------- + + m_gboxSettings = new EditorToolSettings(EditorToolSettings::Default| + EditorToolSettings::Load| + EditorToolSettings::SaveAs| + EditorToolSettings::Ok| + EditorToolSettings::Cancel); + + TQGridLayout* grid = new TQGridLayout(m_gboxSettings->plainPage(), 5, 5); + + TQLabel *label1 = new TQLabel(i18n("Channel:"), m_gboxSettings->plainPage()); + label1->setAlignment ( TQt::AlignRight | TQt::AlignVCenter ); + m_channelCB = new TQComboBox( false, m_gboxSettings->plainPage() ); + m_channelCB->insertItem( i18n("Luminosity") ); + m_channelCB->insertItem( i18n("Red") ); + m_channelCB->insertItem( i18n("Green") ); + m_channelCB->insertItem( i18n("Blue") ); + m_channelCB->insertItem( i18n("Alpha") ); + m_channelCB->setCurrentText( i18n("Luminosity") ); + TQWhatsThis::add( m_channelCB, i18n("<p>Select the histogram channel to display here:<p>" + "<b>Luminosity</b>: display the image's luminosity values.<p>" + "<b>Red</b>: display the red image-channel values.<p>" + "<b>Green</b>: display the green image-channel values.<p>" + "<b>Blue</b>: display the blue image-channel values.<p>" + "<b>Alpha</b>: display the alpha image-channel values. " + "This channel corresponds to the transparency value and " + "is supported by some image formats, such as PNG or TIF.")); + + m_scaleBG = new TQHButtonGroup(m_gboxSettings->plainPage()); + TQWhatsThis::add( m_scaleBG, i18n("<p>Select the histogram scale here.<p>" + "If the image's maximal counts are small, you can use the linear scale.<p>" + "Logarithmic scale can be used when the maximal counts are big; " + "if it is used, all values (small and large) will be visible on the graph.")); + + TQPushButton *linHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( linHistoButton, i18n( "<p>Linear" ) ); + m_scaleBG->insert(linHistoButton, CurvesWidget::LinScaleHistogram); + TDEGlobal::dirs()->addResourceType("histogram-lin", TDEGlobal::dirs()->kde_default("data") + "digikam/data"); + TQString directory = TDEGlobal::dirs()->findResourceDir("histogram-lin", "histogram-lin.png"); + linHistoButton->setPixmap( TQPixmap( directory + "histogram-lin.png" ) ); + linHistoButton->setToggleButton(true); + + TQPushButton *logHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( logHistoButton, i18n( "<p>Logarithmic" ) ); + m_scaleBG->insert(logHistoButton, CurvesWidget::LogScaleHistogram); + TDEGlobal::dirs()->addResourceType("histogram-log", TDEGlobal::dirs()->kde_default("data") + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("histogram-log", "histogram-log.png"); + logHistoButton->setPixmap( TQPixmap( directory + "histogram-log.png" ) ); + logHistoButton->setToggleButton(true); + + m_scaleBG->setExclusive(true); + m_scaleBG->setButton(CurvesWidget::LogScaleHistogram); + m_scaleBG->setFrameShape(TQFrame::NoFrame); + m_scaleBG->setInsideMargin(0); + + TQHBoxLayout* l1 = new TQHBoxLayout(); + l1->addWidget(label1); + l1->addWidget(m_channelCB); + l1->addStretch(10); + l1->addWidget(m_scaleBG); + + // ------------------------------------------------------------- + + TQWidget *curveBox = new TQWidget(m_gboxSettings->plainPage()); + TQGridLayout* gl = new TQGridLayout(curveBox, 4, 2, 0); + + m_histogramWidget = new HistogramWidget(256, 140, curveBox, false, true, true); + TQWhatsThis::add( m_histogramWidget, i18n("<p>Here you can see the target preview image histogram drawing " + "of the selected image channel. This one is re-computed at any " + "curves settings changes.")); + + m_vGradient = new ColorGradientWidget( ColorGradientWidget::Vertical, 10, curveBox ); + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + + TQLabel *spacev = new TQLabel(curveBox); + spacev->setFixedWidth(1); + + m_curvesWidget = new CurvesWidget(256, 256, m_originalImage->bits(), m_originalImage->width(), + m_originalImage->height(), m_originalImage->sixteenBit(), + curveBox); + TQWhatsThis::add( m_curvesWidget, i18n("<p>This is the curve drawing of the selected channel from " + "original image")); + + TQLabel *spaceh = new TQLabel(curveBox); + spaceh->setFixedHeight(1); + + m_hGradient = new ColorGradientWidget( ColorGradientWidget::Horizontal, 10, curveBox ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + + gl->addMultiCellWidget(m_histogramWidget, 0, 0, 2, 2); + gl->addMultiCellWidget(m_vGradient, 2, 2, 0, 0); + gl->addMultiCellWidget(spacev, 2, 2, 1, 1); + gl->addMultiCellWidget(m_curvesWidget, 2, 2, 2, 2); + gl->addMultiCellWidget(spaceh, 3, 3, 2, 2); + gl->addMultiCellWidget(m_hGradient, 4, 4, 2, 2); + gl->setRowSpacing(1, m_gboxSettings->spacingHint()); + + // ------------------------------------------------------------- + + m_curveType = new TQHButtonGroup(m_gboxSettings->plainPage()); + m_curveFree = new TQPushButton(m_curveType); + m_curveType->insert(m_curveFree, FreeDrawing); + TDEGlobal::dirs()->addResourceType("curvefree", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("curvefree", "curvefree.png"); + m_curveFree->setPixmap( TQPixmap( directory + "curvefree.png" ) ); + m_curveFree->setToggleButton(true); + TQToolTip::add( m_curveFree, i18n( "Curve free mode" ) ); + TQWhatsThis::add( m_curveFree, i18n("<p>With this button, you can draw your curve free-hand with the mouse.")); + m_curveSmooth = new TQPushButton(m_curveType); + m_curveType->insert(m_curveSmooth, SmoothDrawing); + TDEGlobal::dirs()->addResourceType("curvemooth", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("curvemooth", "curvemooth.png"); + m_curveSmooth->setPixmap( TQPixmap( directory + "curvemooth.png" ) ); + m_curveSmooth->setToggleButton(true); + TQToolTip::add( m_curveSmooth, i18n( "Curve smooth mode" ) ); + TQWhatsThis::add( m_curveSmooth, i18n("<p>With this button, you constrains the curve type to a smooth line with tension.")); + m_curveType->setExclusive(true); + m_curveType->setButton(SmoothDrawing); + m_curveType->setFrameShape(TQFrame::NoFrame); + + // ------------------------------------------------------------- + + m_pickerColorButtonGroup = new TQHButtonGroup(m_gboxSettings->plainPage()); + m_pickBlack = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickBlack, BlackTonal); + TDEGlobal::dirs()->addResourceType("color-picker-black", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-black", "color-picker-black.png"); + m_pickBlack->setPixmap( TQPixmap( directory + "color-picker-black.png" ) ); + m_pickBlack->setToggleButton(true); + TQToolTip::add( m_pickBlack, i18n( "All channels shadow tone color picker" ) ); + TQWhatsThis::add( m_pickBlack, i18n("<p>With this button, you can pick the color from original image used to set <b>Shadow Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickGray = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickGray, GrayTonal); + TDEGlobal::dirs()->addResourceType("color-picker-grey", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-grey", "color-picker-grey.png"); + m_pickGray->setPixmap( TQPixmap( directory + "color-picker-grey.png" ) ); + m_pickGray->setToggleButton(true); + TQToolTip::add( m_pickGray, i18n( "All channels middle tone color picker" ) ); + TQWhatsThis::add( m_pickGray, i18n("<p>With this button, you can pick the color from original image used to set <b>Middle Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickWhite = new TQPushButton(m_pickerColorButtonGroup); + m_pickerColorButtonGroup->insert(m_pickWhite, WhiteTonal); + TDEGlobal::dirs()->addResourceType("color-picker-white", TDEGlobal::dirs()->kde_default("data") + + "digikam/data"); + directory = TDEGlobal::dirs()->findResourceDir("color-picker-white", "color-picker-white.png"); + m_pickWhite->setPixmap( TQPixmap( directory + "color-picker-white.png" ) ); + m_pickWhite->setToggleButton(true); + TQToolTip::add( m_pickWhite, i18n( "All channels highlight tone color picker" ) ); + TQWhatsThis::add( m_pickWhite, i18n("<p>With this button, you can pick the color from original image used to set <b>Highlight Tone</b> " + "smooth curves point on Red, Green, Blue, and Luminosity channels.")); + m_pickerColorButtonGroup->setExclusive(true); + m_pickerColorButtonGroup->setFrameShape(TQFrame::NoFrame); + + // ------------------------------------------------------------- + + m_resetButton = new TQPushButton(i18n("&Reset"), m_gboxSettings->plainPage()); + m_resetButton->setPixmap( SmallIcon("reload_page", 18) ); + TQToolTip::add( m_resetButton, i18n( "Reset current channel curves' values." ) ); + TQWhatsThis::add( m_resetButton, i18n("<p>If you press this button, all curves' values " + "from the current selected channel " + "will be reset to the default values.")); + + TQHBoxLayout* l3 = new TQHBoxLayout(); + l3->addWidget(m_curveType); + l3->addWidget(m_pickerColorButtonGroup); + l3->addWidget(m_resetButton); + l3->addStretch(10); + + grid->addMultiCellLayout(l1, 0, 0, 1, 5); + grid->addMultiCellWidget(curveBox, 1, 3, 0, 5); + grid->addMultiCellLayout(l3, 4, 4, 1, 5); + grid->setMargin(0); + grid->setSpacing(m_gboxSettings->spacingHint()); + grid->setRowStretch(5, 10); + + setToolSettings(m_gboxSettings); + init(); + + // ------------------------------------------------------------- + + connect(m_curvesWidget, TQ_SIGNAL(signalCurvesChanged()), + this, TQ_SLOT(slotTimer())); + + connect(m_previewWidget, TQ_SIGNAL(spotPositionChangedFromOriginal(const Digikam::DColor&, const TQPoint&)), + this, TQ_SLOT(slotSpotColorChanged(const Digikam::DColor&))); + + connect(m_previewWidget, TQ_SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const TQPoint&)), + this, TQ_SLOT(slotColorSelectedFromTarget(const Digikam::DColor&))); + + connect(m_previewWidget, TQ_SIGNAL(signalResized()), + this, TQ_SLOT(slotEffect())); + + // ------------------------------------------------------------- + // ComboBox slots. + + connect(m_channelCB, TQ_SIGNAL(activated(int)), + this, TQ_SLOT(slotChannelChanged(int))); + + connect(m_scaleBG, TQ_SIGNAL(released(int)), + this, TQ_SLOT(slotScaleChanged(int))); + + connect(m_curveType, TQ_SIGNAL(clicked(int)), + this, TQ_SLOT(slotCurveTypeChanged(int))); + + // ------------------------------------------------------------- + // Buttons slots. + + connect(m_resetButton, TQ_SIGNAL(clicked()), + this, TQ_SLOT(slotResetCurrentChannel())); + + connect(m_pickerColorButtonGroup, TQ_SIGNAL(released(int)), + this, TQ_SLOT(slotPickerColorButtonActived())); +} + +AdjustCurvesTool::~AdjustCurvesTool() +{ + if (m_destinationPreviewData) + delete [] m_destinationPreviewData; +} + +void AdjustCurvesTool::slotPickerColorButtonActived() +{ + // Save previous rendering mode and toggle to original image. + m_currentPreviewMode = m_previewWidget->getRenderingPreviewMode(); + m_previewWidget->setRenderingPreviewMode(ImageGuideWidget::PreviewOriginalImage); +} + +void AdjustCurvesTool::slotSpotColorChanged(const DColor &color) +{ + DColor sc = color; + + if ( m_pickBlack->isOn() ) + { + // Black tonal curves point. + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::ValueChannel, 1, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 42*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::RedChannel, 1, TQPoint(sc.red(), 42*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::GreenChannel, 1, TQPoint(sc.green(), 42*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::BlueChannel, 1, TQPoint(sc.blue(), 42*m_histoSegments/256)); + m_pickBlack->setOn(false); + } + else if ( m_pickGray->isOn() ) + { + // Gray tonal curves point. + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::ValueChannel, 8, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 128*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::RedChannel, 8, TQPoint(sc.red(), 128*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::GreenChannel, 8, TQPoint(sc.green(), 128*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::BlueChannel, 8, TQPoint(sc.blue(), 128*m_histoSegments/256)); + m_pickGray->setOn(false); + } + else if ( m_pickWhite->isOn() ) + { + // White tonal curves point. + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::ValueChannel, 15, + TQPoint(TQMAX(TQMAX(sc.red(), sc.green()), sc.blue()), 213*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::RedChannel, 15, TQPoint(sc.red(), 213*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::GreenChannel, 15, TQPoint(sc.green(), 213*m_histoSegments/256)); + m_curvesWidget->curves()->setCurvePoint(ImageHistogram::BlueChannel, 15, TQPoint(sc.blue(), 213*m_histoSegments/256)); + m_pickWhite->setOn(false); + } + else + { + m_curvesWidget->setCurveGuide(color); + return; + } + + // Calculate Red, green, blue curves. + + for (int i = ImageHistogram::ValueChannel ; i <= ImageHistogram::BlueChannel ; i++) + m_curvesWidget->curves()->curvesCalculateCurve(i); + + m_curvesWidget->repaint(false); + + // restore previous rendering mode. + m_previewWidget->setRenderingPreviewMode(m_currentPreviewMode); + + slotEffect(); +} + +void AdjustCurvesTool::slotColorSelectedFromTarget( const DColor &color ) +{ + m_histogramWidget->setHistogramGuideByColor(color); +} + +void AdjustCurvesTool::slotResetCurrentChannel() +{ + m_curvesWidget->curves()->curvesChannelReset(m_channelCB->currentItem()); + + m_curvesWidget->repaint(); + slotEffect(); + m_histogramWidget->reset(); +} + +void AdjustCurvesTool::slotEffect() +{ + ImageIface* iface = m_previewWidget->imageIface(); + uchar *orgData = iface->getPreviewImage(); + int w = iface->previewWidth(); + int h = iface->previewHeight(); + bool sb = iface->previewSixteenBit(); + + // Create the new empty destination image data space. + m_histogramWidget->stopHistogramComputation(); + + if (m_destinationPreviewData) + delete [] m_destinationPreviewData; + + m_destinationPreviewData = new uchar[w*h*(sb ? 8 : 4)]; + + // Calculate the LUT to apply on the image. + m_curvesWidget->curves()->curvesLutSetup(ImageHistogram::AlphaChannel); + + // Apply the lut to the image. + m_curvesWidget->curves()->curvesLutProcess(orgData, m_destinationPreviewData, w, h); + + iface->putPreviewImage(m_destinationPreviewData); + m_previewWidget->updatePreview(); + + // Update histogram. + m_histogramWidget->updateData(m_destinationPreviewData, w, h, sb, 0, 0, 0, false); + delete [] orgData; +} + +void AdjustCurvesTool::finalRendering() +{ + kapp->setOverrideCursor( KCursor::waitCursor() ); + ImageIface* iface = m_previewWidget->imageIface(); + uchar *orgData = iface->getOriginalImage(); + int w = iface->originalWidth(); + int h = iface->originalHeight(); + bool sb = iface->originalSixteenBit(); + + // Create the new empty destination image data space. + uchar* desData = new uchar[w*h*(sb ? 8 : 4)]; + + // Calculate the LUT to apply on the image. + m_curvesWidget->curves()->curvesLutSetup(ImageHistogram::AlphaChannel); + + // Apply the lut to the image. + m_curvesWidget->curves()->curvesLutProcess(orgData, desData, w, h); + + iface->putOriginalImage(i18n("Adjust Curves"), desData); + kapp->restoreOverrideCursor(); + + delete [] orgData; + delete [] desData; +} + +void AdjustCurvesTool::slotChannelChanged(int channel) +{ + switch(channel) + { + case LuminosityChannel: + m_histogramWidget->m_channelType = HistogramWidget::ValueHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + m_curvesWidget->m_channelType = CurvesWidget::ValueHistogram; + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + break; + + case RedChannel: + m_histogramWidget->m_channelType = HistogramWidget::RedChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "red" ) ); + m_curvesWidget->m_channelType = CurvesWidget::RedChannelHistogram; + m_vGradient->setColors( TQColor( "red" ), TQColor( "black" ) ); + break; + + case GreenChannel: + m_histogramWidget->m_channelType = HistogramWidget::GreenChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "green" ) ); + m_curvesWidget->m_channelType = CurvesWidget::GreenChannelHistogram; + m_vGradient->setColors( TQColor( "green" ), TQColor( "black" ) ); + break; + + case BlueChannel: + m_histogramWidget->m_channelType = HistogramWidget::BlueChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "blue" ) ); + m_curvesWidget->m_channelType = CurvesWidget::BlueChannelHistogram; + m_vGradient->setColors( TQColor( "blue" ), TQColor( "black" ) ); + break; + + case AlphaChannel: + m_histogramWidget->m_channelType = HistogramWidget::AlphaChannelHistogram; + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); + m_curvesWidget->m_channelType = CurvesWidget::AlphaChannelHistogram; + m_vGradient->setColors( TQColor( "white" ), TQColor( "black" ) ); + break; + } + + m_curveType->setButton(m_curvesWidget->curves()->getCurveType(channel)); + + m_curvesWidget->repaint(false); + m_histogramWidget->repaint(false); +} + +void AdjustCurvesTool::slotScaleChanged(int scale) +{ + m_curvesWidget->m_scaleType = scale; + m_histogramWidget->m_scaleType = scale; + m_histogramWidget->repaint(false); + m_curvesWidget->repaint(false); +} + +void AdjustCurvesTool::slotCurveTypeChanged(int type) +{ + switch(type) + { + case SmoothDrawing: + { + m_curvesWidget->curves()->setCurveType(m_curvesWidget->m_channelType, ImageCurves::CURVE_SMOOTH); + m_pickerColorButtonGroup->setEnabled(true); + break; + } + + case FreeDrawing: + { + m_curvesWidget->curves()->setCurveType(m_curvesWidget->m_channelType, ImageCurves::CURVE_FREE); + m_pickerColorButtonGroup->setEnabled(false); + break; + } + } + + m_curvesWidget->curveTypeChanged(); +} + +void AdjustCurvesTool::readSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("adjustcurves Tool"); + + m_channelCB->setCurrentItem(config->readNumEntry("Histogram Channel", 0)); // Luminosity. + m_scaleBG->setButton(config->readNumEntry("Histogram Scale", HistogramWidget::LogScaleHistogram)); + + m_curvesWidget->reset(); + + for (int i = 0 ; i < 5 ; i++) + { + m_curvesWidget->curves()->curvesChannelReset(i); + m_curvesWidget->curves()->setCurveType(i, (ImageCurves::CurveType)config->readNumEntry(TQString("CurveTypeChannel%1").arg(i), + ImageCurves::CURVE_SMOOTH)); + + for (int j = 0 ; j < 17 ; j++) + { + TQPoint disable(-1, -1); + TQPoint p = config->readPointEntry(TQString("CurveAjustmentChannel%1Point%2").arg(i).arg(j), &disable); + + if (m_originalImage->sixteenBit() && p.x() != -1) + { + p.setX(p.x()*255); + p.setY(p.y()*255); + } + + m_curvesWidget->curves()->setCurvePoint(i, j, p); + } + + m_curvesWidget->curves()->curvesCalculateCurve(i); + } + + m_histogramWidget->reset(); + slotChannelChanged(m_channelCB->currentItem()); + slotScaleChanged(m_scaleBG->selectedId()); + slotEffect(); +} + +void AdjustCurvesTool::writeSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("adjustcurves Tool"); + config->writeEntry("Histogram Channel", m_channelCB->currentItem()); + config->writeEntry("Histogram Scale", m_scaleBG->selectedId()); + + for (int i = 0 ; i < 5 ; i++) + { + config->writeEntry(TQString("CurveTypeChannel%1").arg(i), m_curvesWidget->curves()->getCurveType(i)); + + for (int j = 0 ; j < 17 ; j++) + { + TQPoint p = m_curvesWidget->curves()->getCurvePoint(i, j); + + if (m_originalImage->sixteenBit() && p.x() != -1) + { + p.setX(p.x()/255); + p.setY(p.y()/255); + } + + config->writeEntry(TQString("CurveAjustmentChannel%1Point%2").arg(i).arg(j), p); + } + } + + m_previewWidget->writeSettings(); + config->sync(); +} + +void AdjustCurvesTool::slotResetSettings() +{ + for (int channel = 0 ; channel < 5 ; channel++) + m_curvesWidget->curves()->curvesChannelReset(channel); + + m_curvesWidget->reset(); + slotEffect(); + m_histogramWidget->reset(); +} + +void AdjustCurvesTool::slotLoadSettings() +{ + KURL loadCurvesFile; + + loadCurvesFile = KFileDialog::getOpenURL(TDEGlobalSettings::documentPath(), + TQString( "*" ), kapp->activeWindow(), + TQString( i18n("Select Gimp Curves File to Load")) ); + if( loadCurvesFile.isEmpty() ) + return; + + if ( m_curvesWidget->curves()->loadCurvesFromGimpCurvesFile( loadCurvesFile ) == false ) + { + KMessageBox::error(kapp->activeWindow(), i18n("Cannot load from the Gimp curves text file.")); + return; + } + + // Refresh the current curves config. + slotChannelChanged(m_channelCB->currentItem()); + slotEffect(); +} + +void AdjustCurvesTool::slotSaveAsSettings() +{ + KURL saveCurvesFile; + + saveCurvesFile = KFileDialog::getSaveURL(TDEGlobalSettings::documentPath(), + TQString( "*" ), kapp->activeWindow(), + TQString( i18n("Gimp Curves File to Save")) ); + if( saveCurvesFile.isEmpty() ) + return; + + if ( m_curvesWidget->curves()->saveCurvesToGimpCurvesFile( saveCurvesFile ) == false ) + { + KMessageBox::error(kapp->activeWindow(), i18n("Cannot save to the Gimp curves text file.")); + return; + } + + // Refresh the current curves config. + slotChannelChanged(m_channelCB->currentItem()); +} + +} // NameSpace DigikamAdjustCurvesImagesPlugin diff --git a/src/imageplugins/adjustcurves/adjustcurvestool.h b/src/imageplugins/adjustcurves/adjustcurvestool.h new file mode 100644 index 00000000..4a380530 --- /dev/null +++ b/src/imageplugins/adjustcurves/adjustcurvestool.h @@ -0,0 +1,145 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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 ADJUSTCURVESTOOL_H +#define ADJUSTCURVESTOOL_H + +// Digikam includes. + +#include "editortool.h" + +// Local includes. + +class TQComboBox; +class TQPushButton; +class TQHButtonGroup; + +namespace Digikam +{ +class CurvesWidget; +class HistogramWidget; +class ColorGradientWidget; +class EditorToolSettings; +class ImageWidget; +class DImg; +class DColor; +} + +namespace DigikamAdjustCurvesImagesPlugin +{ + +class AdjustCurvesTool : public Digikam::EditorTool +{ + TQ_OBJECT + + +public: + + AdjustCurvesTool(TQObject *parent); + ~AdjustCurvesTool(); + +private: + + void readSettings(); + void writeSettings(); + void finalRendering(); + +private slots: + + void slotSaveAsSettings(); + void slotLoadSettings(); + void slotEffect(); + void slotResetSettings(); + void slotResetCurrentChannel(); + void slotChannelChanged(int channel); + void slotScaleChanged(int scale); + void slotCurveTypeChanged(int type); + void slotSpotColorChanged(const Digikam::DColor& color); + void slotColorSelectedFromTarget(const Digikam::DColor& color); + void slotPickerColorButtonActived(); + +private: + + enum ColorPicker + { + BlackTonal=0, + GrayTonal, + WhiteTonal + }; + + enum ColorChannel + { + LuminosityChannel=0, + RedChannel, + GreenChannel, + BlueChannel, + AlphaChannel + }; + + enum CurvesDrawingType + { + SmoothDrawing=0, + FreeDrawing + }; + + enum HistogramScale + { + Linear=0, + Logarithmic + }; + + uchar *m_destinationPreviewData; + + int m_histoSegments; + int m_currentPreviewMode; + + TQComboBox *m_channelCB; + + TQPushButton *m_resetButton; + TQPushButton *m_pickBlack; + TQPushButton *m_pickGray; + TQPushButton *m_pickWhite; + TQPushButton *m_curveFree; + TQPushButton *m_curveSmooth; + + TQHButtonGroup *m_pickerColorButtonGroup; + TQHButtonGroup *m_scaleBG; + TQHButtonGroup *m_curveType; + + Digikam::CurvesWidget *m_curvesWidget; + + Digikam::HistogramWidget *m_histogramWidget; + + Digikam::ColorGradientWidget *m_hGradient; + Digikam::ColorGradientWidget *m_vGradient; + + Digikam::ImageWidget *m_previewWidget; + + Digikam::EditorToolSettings *m_gboxSettings; + + Digikam::DImg *m_originalImage; +}; + +} // NameSpace DigikamAdjustCurvesImagesPlugin + +#endif /* ADJUSTCURVESTOOL_H */ diff --git a/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves.desktop b/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves.desktop new file mode 100644 index 00000000..377c2a33 --- /dev/null +++ b/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Name=ImagePlugin_AdjustCurves +Name[bg]=Приставка за снимки - Настройка на кривите +Name[da]=Billedplugin_Kurvejustering +Name[el]=ΠρόσθετοΕικόνας_ΠροσαρμογήΚαμπύλων +Name[fi]=TasonsäätöKäyrä +Name[hr]=Podešavanje krivulja +Name[it]=PluginImmagini_RegolaCurve +Name[nl]=Afbeeldingsplugin_CurvesAanpassen +Name[sr]=Подешавање кривих +Name[sr@Latn]=Podešavanje krivih +Name[sv]=Insticksprogram för justering av kurvor +Name[tr]=ResimEklentisi_EğriAyarla +Name[xx]=xxImagePlugin_AdjustCurvesxx +Type=Service +X-TDE-ServiceTypes=Digikam/ImagePlugin +Encoding=UTF-8 + +Comment=Image histogram adjust curves plugin for digiKam +Comment[bg]=Приставка на digiKam за настройка кривите на хистограмите на снимки +Comment[ca]=Connector pel digiKam d'ajust de les corbes de l'histograma d'imatges +Comment[da]=Plugin til histogramkurvejustering i Digikam +Comment[de]=digiKam-Modul zur Justierung der Farbkurven +Comment[el]=Πρόσθετο προσαρμογής των καμπύλων του ιστογράμματος εικόνας για το digiKam +Comment[es]=Histograma de imágenes, plugin de ajuste de curvas para digiKam +Comment[et]=DigiKami pildi histogrammi kõverate kohendamise plugin +Comment[fa]=وصلۀ منحنیهای تنظیم سابقهنمای تصویر برای digiKam +Comment[fi]=Muokkaa värikanavien raja-arvoja +Comment[fr]=Module externe pour ajuster les courbes de l'histogramme dans digiKam +Comment[gl]=Un plugin de digiKam para o axuste das curvas do histograma da imaxe +Comment[hr]=digiKam dodatak za histogramsko podešavanje krivulja +Comment[is]=Íforrit fyrir digiKam sem breytir ferlum (curves) í stuðlariti myndar +Comment[it]=Plugin di regolazione delle curve degli istogrammi delle immagini per digiKam +Comment[ja]=digiKam カーブ補正プラグイン +Comment[nds]=digiKam-Moduul för't Topassen vun Histogramm-Klöörbagens +Comment[nl]=Digikam-plugin voor curvesaanpassing van afbeeldingshistogram +Comment[pa]=ਡਿਜ਼ੀਕੈਮ ਲਈ ਚਿੱਤਰ ਹਿਸਟੋਗਰਾਮ ਅਨੁਕੂਲ ਚਾਪ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka do programu digiKam dostosowująca krzywe i histogram dla obrazu +Comment[pt]=Um 'plugin' do digiKam de ajuste de curvas do histograma da imagem +Comment[pt_BR]=Plugin de ajuste de curvas do histograma da imagem +Comment[ru]=Модуль digiKam подстройки кривых гистограммы изображения +Comment[sk]=digiKam plugin histogramu kriviek úprav obrázku +Comment[sr]=digiKam-ов прикључак за подешавање кривих хистограма слике +Comment[sr@Latn]=digiKam-ov priključak za podešavanje krivih histograma slike +Comment[sv]=Digikam insticksprogram för justering av kurvor i bildhistogram +Comment[tr]=digiKam için resim histogram eğrileri ayarlama eklentisi +Comment[uk]=Втулок коригування кривих гістограми зображень для digiKam +Comment[vi]=Phần bổ sung biểu đồ tần xuất điều chỉnh đường cong ảnh cho digiKam +Comment[xx]=xxImage histogram adjust curves plugin for digiKamxx + +X-TDE-Library=digikamimageplugin_adjustcurves +author=Caulier Gilles, caulier dot gilles at gmail dot com diff --git a/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves_ui.rc b/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves_ui.rc new file mode 100644 index 00000000..c87c2c1e --- /dev/null +++ b/src/imageplugins/adjustcurves/digikamimageplugin_adjustcurves_ui.rc @@ -0,0 +1,20 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui version="5" name="digikamimageplugin_adjustcurves" > + + <MenuBar> + + <Menu name="Color" ><text>&Color</text> + <Action name="imageplugin_adjustcurves" /> + </Menu> + + </MenuBar> + + <ToolBar name="ToolBar" > + <text>Main Toolbar</text> + </ToolBar> + + <ActionProperties> + <Action name="imageplugin_adjustcurves" /> + </ActionProperties> + +</kpartgui> diff --git a/src/imageplugins/adjustcurves/imageplugin_adjustcurves.cpp b/src/imageplugins/adjustcurves/imageplugin_adjustcurves.cpp new file mode 100644 index 00000000..11b6e53f --- /dev/null +++ b/src/imageplugins/adjustcurves/imageplugin_adjustcurves.cpp @@ -0,0 +1,70 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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 "adjustcurvestool.h" +#include "imageplugin_adjustcurves.h" +#include "imageplugin_adjustcurves.moc" + +using namespace DigikamAdjustCurvesImagesPlugin; + +K_EXPORT_COMPONENT_FACTORY( digikamimageplugin_adjustcurves, + KGenericFactory<ImagePlugin_AdjustCurves>("digikamimageplugin_adjustcurves")); + +ImagePlugin_AdjustCurves::ImagePlugin_AdjustCurves(TQObject *parent, const char*, const TQStringList&) + : Digikam::ImagePlugin(parent, "ImagePlugin_AdjustCurves") +{ + m_curvesAction = new TDEAction(i18n("Curves Adjust..."), "adjustcurves", + CTRL+SHIFT+Key_M, // NOTE: Photoshop 7 use CTRL+M (but it's used in KDE to toogle menu bar). + this, TQ_SLOT(slotCurvesAdjust()), + actionCollection(), "imageplugin_adjustcurves"); + + setXMLFile("digikamimageplugin_adjustcurves_ui.rc"); + + DDebug() << "ImagePlugin_AdjustCurves plugin loaded" << endl; +} + +ImagePlugin_AdjustCurves::~ImagePlugin_AdjustCurves() +{ +} + +void ImagePlugin_AdjustCurves::setEnabledActions(bool enable) +{ + m_curvesAction->setEnabled(enable); +} + +void ImagePlugin_AdjustCurves::slotCurvesAdjust() +{ + AdjustCurvesTool *curves = new AdjustCurvesTool(this); + loadTool(curves); +} diff --git a/src/imageplugins/adjustcurves/imageplugin_adjustcurves.h b/src/imageplugins/adjustcurves/imageplugin_adjustcurves.h new file mode 100644 index 00000000..f8e43578 --- /dev/null +++ b/src/imageplugins/adjustcurves/imageplugin_adjustcurves.h @@ -0,0 +1,56 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-12-01 + * Description : image histogram adjust curves. + * + * 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_ADJUSTCURVES_H +#define IMAGEPLUGIN_ADJUSTCURVES_H + +// Digikam includes. + +#include "imageplugin.h" +#include "digikam_export.h" + +class TDEAction; + +class DIGIKAMIMAGEPLUGINS_EXPORT ImagePlugin_AdjustCurves : public Digikam::ImagePlugin +{ + TQ_OBJECT + + +public: + + ImagePlugin_AdjustCurves(TQObject *parent, const char* name, + const TQStringList &args); + ~ImagePlugin_AdjustCurves(); + + void setEnabledActions(bool enable); + +private slots: + + void slotCurvesAdjust(); + +private: + + TDEAction *m_curvesAction; +}; + +#endif /* IMAGEPLUGIN_ADJUSTCURVES_H */ |