diff options
Diffstat (limited to 'digikam/imageplugins/coreplugin/imageeffect_redeye.cpp')
-rw-r--r-- | digikam/imageplugins/coreplugin/imageeffect_redeye.cpp | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/digikam/imageplugins/coreplugin/imageeffect_redeye.cpp b/digikam/imageplugins/coreplugin/imageeffect_redeye.cpp index ad5054d..9a4c435 100644 --- a/digikam/imageplugins/coreplugin/imageeffect_redeye.cpp +++ b/digikam/imageplugins/coreplugin/imageeffect_redeye.cpp @@ -22,22 +22,22 @@ * * ============================================================ */ -// Qt includes. - -#include <qcolor.h> -#include <qhbox.h> -#include <qhgroupbox.h> -#include <qvgroupbox.h> -#include <qhbuttongroup.h> -#include <qvbox.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qframe.h> -#include <qlabel.h> -#include <qpushbutton.h> -#include <qcombobox.h> -#include <qwhatsthis.h> -#include <qtooltip.h> +// TQt includes. + +#include <tqcolor.h> +#include <tqhbox.h> +#include <tqhgroupbox.h> +#include <tqvgroupbox.h> +#include <tqhbuttongroup.h> +#include <tqvbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqframe.h> +#include <tqlabel.h> +#include <tqpushbutton.h> +#include <tqcombobox.h> +#include <tqwhatsthis.h> +#include <tqtooltip.h> // KDE includes. @@ -68,8 +68,8 @@ namespace DigikamImagesPluginCore { -ImageEffect_RedEye::ImageEffect_RedEye(QWidget* parent) - : Digikam::ImageDlgBase(parent, i18n("Red Eye Reduction"), "redeye", false) +ImageEffect_RedEye::ImageEffect_RedEye(TQWidget* tqparent) + : Digikam::ImageDlgBase(tqparent, i18n("Red Eye Reduction"), "redeye", false) { m_destinationPreviewData = 0; setHelp("redeyecorrectiontool.anchor", "digikam"); @@ -82,48 +82,48 @@ ImageEffect_RedEye::ImageEffect_RedEye(QWidget* parent) // ------------------------------------------------------------- - QWidget *gboxSettings = new QWidget(plainPage()); - QGridLayout* gridSettings = new QGridLayout(gboxSettings, 11, 4, spacingHint()); + TQWidget *gboxSettings = new TQWidget(plainPage()); + TQGridLayout* gridSettings = new TQGridLayout(gboxSettings, 11, 4, spacingHint()); - QLabel *label1 = new QLabel(i18n("Channel:"), gboxSettings); - label1->setAlignment ( Qt::AlignRight | Qt::AlignVCenter ); - m_channelCB = new QComboBox( false, gboxSettings ); + TQLabel *label1 = new TQLabel(i18n("Channel:"), gboxSettings); + label1->tqsetAlignment ( 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") ); - QWhatsThis::add( m_channelCB, i18n("<p>Select the histogram channel to display here:<p>" + 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>")); - m_scaleBG = new QHButtonGroup(gboxSettings); + m_scaleBG = new TQHButtonGroup(gboxSettings); m_scaleBG->setExclusive(true); - m_scaleBG->setFrameShape(QFrame::NoFrame); + m_scaleBG->setFrameShape(TQFrame::NoFrame); m_scaleBG->setInsideMargin(0); - QWhatsThis::add( m_scaleBG, i18n("<p>Select the histogram scale here.<p>" + TQWhatsThis::add( m_scaleBG, i18n("<p>Select the histogram scale here.<p>" "If the image's maximum counts are small, you can use the linear scale.<p>" "The logarithmic scale can be used when the maximal counts are big " "to show all values (small and large) on the graph.")); - QPushButton *linHistoButton = new QPushButton( m_scaleBG ); - QToolTip::add( linHistoButton, i18n( "<p>Linear" ) ); + TQPushButton *linHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( linHistoButton, i18n( "<p>Linear" ) ); m_scaleBG->insert(linHistoButton, Digikam::HistogramWidget::LinScaleHistogram); KGlobal::dirs()->addResourceType("histogram-lin", KGlobal::dirs()->kde_default("data") + "digikam/data"); - QString directory = KGlobal::dirs()->findResourceDir("histogram-lin", "histogram-lin.png"); - linHistoButton->setPixmap( QPixmap( directory + "histogram-lin.png" ) ); + TQString directory = KGlobal::dirs()->findResourceDir("histogram-lin", "histogram-lin.png"); + linHistoButton->setPixmap( TQPixmap( directory + "histogram-lin.png" ) ); linHistoButton->setToggleButton(true); - QPushButton *logHistoButton = new QPushButton( m_scaleBG ); - QToolTip::add( logHistoButton, i18n( "<p>Logarithmic" ) ); + TQPushButton *logHistoButton = new TQPushButton( m_scaleBG ); + TQToolTip::add( logHistoButton, i18n( "<p>Logarithmic" ) ); m_scaleBG->insert(logHistoButton, Digikam::HistogramWidget::LogScaleHistogram); KGlobal::dirs()->addResourceType("histogram-log", KGlobal::dirs()->kde_default("data") + "digikam/data"); directory = KGlobal::dirs()->findResourceDir("histogram-log", "histogram-log.png"); - logHistoButton->setPixmap( QPixmap( directory + "histogram-log.png" ) ); + logHistoButton->setPixmap( TQPixmap( directory + "histogram-log.png" ) ); logHistoButton->setToggleButton(true); - QHBoxLayout* l1 = new QHBoxLayout(); + TQHBoxLayout* l1 = new TQHBoxLayout(); l1->addWidget(label1); l1->addWidget(m_channelCB); l1->addStretch(10); @@ -131,47 +131,47 @@ ImageEffect_RedEye::ImageEffect_RedEye(QWidget* parent) // ------------------------------------------------------------- - QVBox *histoBox = new QVBox(gboxSettings); + TQVBox *histoBox = new TQVBox(gboxSettings); m_histogramWidget = new Digikam::HistogramWidget(256, 140, histoBox, false, true, true); - QWhatsThis::add( m_histogramWidget, i18n("<p>Here you can see the target preview image histogram " + TQWhatsThis::add( m_histogramWidget, i18n("<p>Here you can see the target preview image histogram " "of the selected image channel. It is " "updated upon setting changes.")); - QLabel *space = new QLabel(histoBox); + TQLabel *space = new TQLabel(histoBox); space->setFixedHeight(1); m_hGradient = new Digikam::ColorGradientWidget(Digikam::ColorGradientWidget::Horizontal, 10, histoBox); - m_hGradient->setColors(QColor("black"), QColor("white")); + m_hGradient->setColors(TQColor("black"), TQColor("white")); // ------------------------------------------------------------- - m_thresholdLabel = new QLabel(i18n("Sensitivity:"), gboxSettings); + m_thresholdLabel = new TQLabel(i18n("Sensitivity:"), gboxSettings); m_redThreshold = new KIntNumInput(gboxSettings); m_redThreshold->setRange(10, 90, 1, true); m_redThreshold->setValue(20); - QWhatsThis::add(m_redThreshold, i18n("<p>Sets the red color pixels selection threshold. " + TQWhatsThis::add(m_redThreshold, i18n("<p>Sets the red color pixels selection threshold. " "Low values will select more red color pixels (agressive correction), high " "values less (mild correction). Use low value if eye have been selected " "exactly. Use high value if other parts of the face are also selected.")); - m_smoothLabel = new QLabel(i18n("Smooth:"), gboxSettings); + m_smoothLabel = new TQLabel(i18n("Smooth:"), gboxSettings); m_smoothLevel = new KIntNumInput(gboxSettings); m_smoothLevel->setRange(0, 5, 1, true); m_smoothLevel->setValue(1); - QWhatsThis::add(m_smoothLevel, i18n("<p>Sets the smoothness value when blurring the border " + TQWhatsThis::add(m_smoothLevel, i18n("<p>Sets the smoothness value when blurring the border " "of the changed pixels. " "This leads to a more naturally looking pupil.")); - QLabel *label3 = new QLabel(i18n("Coloring Tint:"), gboxSettings); + TQLabel *label3 = new TQLabel(i18n("Coloring Tint:"), gboxSettings); m_HSSelector = new KHSSelector(gboxSettings); m_VSelector = new KValueSelector(gboxSettings); m_HSSelector->setMinimumSize(200, 142); m_VSelector->setMinimumSize(26, 142); - QWhatsThis::add(m_HSSelector, i18n("<p>Sets a custom color to re-colorize the eyes.")); + TQWhatsThis::add(m_HSSelector, i18n("<p>Sets a custom color to re-colorize the eyes.")); - QLabel *label4 = new QLabel(i18n("Tint Level:"), gboxSettings); + TQLabel *label4 = new TQLabel(i18n("Tint Level:"), gboxSettings); m_tintLevel = new KIntNumInput(gboxSettings); m_tintLevel->setRange(1, 200, 1, true); m_tintLevel->setValue(128); - QWhatsThis::add(m_tintLevel, i18n("<p>Set the tint level to adjust the luminosity of " + TQWhatsThis::add(m_tintLevel, i18n("<p>Set the tint level to adjust the luminosity of " "the new color of the pupil.")); gridSettings->addMultiCellLayout(l1, 0, 0, 0, 4); @@ -191,32 +191,32 @@ ImageEffect_RedEye::ImageEffect_RedEye(QWidget* parent) // ------------------------------------------------------------- - connect(m_channelCB, SIGNAL(activated(int)), - this, SLOT(slotChannelChanged(int))); + connect(m_channelCB, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotChannelChanged(int))); - connect(m_scaleBG, SIGNAL(released(int)), - this, SLOT(slotScaleChanged(int))); + connect(m_scaleBG, TQT_SIGNAL(released(int)), + this, TQT_SLOT(slotScaleChanged(int))); - connect(m_previewWidget, SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const QPoint&)), - this, SLOT(slotColorSelectedFromTarget(const Digikam::DColor&))); + connect(m_previewWidget, TQT_SIGNAL(spotPositionChangedFromTarget(const Digikam::DColor&, const TQPoint&)), + this, TQT_SLOT(slotColorSelectedFromTarget(const Digikam::DColor&))); - connect(m_previewWidget, SIGNAL(signalResized()), - this, SLOT(slotEffect())); + connect(m_previewWidget, TQT_SIGNAL(signalResized()), + this, TQT_SLOT(slotEffect())); - connect(m_redThreshold, SIGNAL(valueChanged(int)), - this, SLOT(slotTimer())); + connect(m_redThreshold, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotTimer())); - connect(m_smoothLevel, SIGNAL(valueChanged(int)), - this, SLOT(slotTimer())); + connect(m_smoothLevel, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotTimer())); - connect(m_HSSelector, SIGNAL(valueChanged(int, int)), - this, SLOT(slotHSChanged(int, int))); + connect(m_HSSelector, TQT_SIGNAL(valueChanged(int, int)), + this, TQT_SLOT(slotHSChanged(int, int))); - connect(m_VSelector, SIGNAL(valueChanged(int)), - this, SLOT(slotTimer())); + connect(m_VSelector, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotTimer())); - connect(m_tintLevel, SIGNAL(valueChanged(int)), - this, SLOT(slotTimer())); + connect(m_tintLevel, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotTimer())); } ImageEffect_RedEye::~ImageEffect_RedEye() @@ -236,7 +236,7 @@ void ImageEffect_RedEye::slotHSChanged(int h, int s) m_VSelector->setHue(h); m_VSelector->setSaturation(s); m_VSelector->updateContents(); - m_VSelector->repaint(false); + m_VSelector->tqrepaint(false); m_VSelector->blockSignals(false); slotTimer(); } @@ -247,32 +247,32 @@ void ImageEffect_RedEye::slotChannelChanged(int channel) { case LuminosityChannel: m_histogramWidget->m_channelType = Digikam::HistogramWidget::ValueHistogram; - m_hGradient->setColors( QColor( "black" ), QColor( "white" ) ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "white" ) ); break; case RedChannel: m_histogramWidget->m_channelType = Digikam::HistogramWidget::RedChannelHistogram; - m_hGradient->setColors( QColor( "black" ), QColor( "red" ) ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "red" ) ); break; case GreenChannel: m_histogramWidget->m_channelType = Digikam::HistogramWidget::GreenChannelHistogram; - m_hGradient->setColors( QColor( "black" ), QColor( "green" ) ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "green" ) ); break; case BlueChannel: m_histogramWidget->m_channelType = Digikam::HistogramWidget::BlueChannelHistogram; - m_hGradient->setColors( QColor( "black" ), QColor( "blue" ) ); + m_hGradient->setColors( TQColor( "black" ), TQColor( "blue" ) ); break; } - m_histogramWidget->repaint(false); + m_histogramWidget->tqrepaint(false); } void ImageEffect_RedEye::slotScaleChanged(int scale) { m_histogramWidget->m_scaleType = scale; - m_histogramWidget->repaint(false); + m_histogramWidget->tqrepaint(false); } void ImageEffect_RedEye::slotColorSelectedFromTarget(const Digikam::DColor& color) @@ -394,10 +394,10 @@ void ImageEffect_RedEye::finalRendering() void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) { - Digikam::DImg mask(selection.width(), selection.height(), selection.sixteenBit(), true, + Digikam::DImg tqmask(selection.width(), selection.height(), selection.sixteenBit(), true, selection.bits(), true); - selection = mask.copy(); + selection = tqmask.copy(); float redThreshold = m_redThreshold->value()/10.0; int hue = m_HSSelector->xValue(); int sat = m_HSSelector->yValue(); @@ -437,12 +437,12 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) green_norm *= coloring.green() / level; blue_norm *= coloring.blue() / level; - // Perform a red color pixels detection in selection image and create a correction mask using an alpha channel. + // Perform a red color pixels detection in selection image and create a correction tqmask using an alpha channel. if (!selection.sixteenBit()) // 8 bits image. { uchar* ptr = selection.bits(); - uchar* mptr = mask.bits(); + uchar* mptr = tqmask.bits(); uchar r, g, b, r1, g1, b1; for (uint i = 0 ; i < selection.width() * selection.height() ; i++) @@ -454,22 +454,22 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) if (r >= ( redThreshold * g)) { - r1 = QMIN(255, (int)(red_norm * (red_chan.red_gain * r + + r1 = TQMIN(255, (int)(red_norm * (red_chan.red_gain * r + red_chan.green_gain * g + red_chan.blue_gain * b))); - g1 = QMIN(255, (int)(green_norm * (green_chan.red_gain * r + + g1 = TQMIN(255, (int)(green_norm * (green_chan.red_gain * r + green_chan.green_gain * g + green_chan.blue_gain * b))); - b1 = QMIN(255, (int)(blue_norm * (blue_chan.red_gain * r + + b1 = TQMIN(255, (int)(blue_norm * (blue_chan.red_gain * r + blue_chan.green_gain * g + blue_chan.blue_gain * b))); mptr[0] = b1; mptr[1] = g1; mptr[2] = r1; - mptr[3] = QMIN( (int)((r-g) / 150.0 * 255.0), 255); + mptr[3] = TQMIN( (int)((r-g) / 150.0 * 255.0), 255); } ptr += 4; @@ -479,7 +479,7 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) else // 16 bits image. { unsigned short* ptr = (unsigned short*)selection.bits(); - unsigned short* mptr = (unsigned short*)mask.bits(); + unsigned short* mptr = (unsigned short*)tqmask.bits(); unsigned short r, g, b, r1, g1, b1; for (uint i = 0 ; i < selection.width() * selection.height() ; i++) @@ -491,22 +491,22 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) if (r >= ( redThreshold * g)) { - r1 = QMIN(65535, (int)(red_norm * (red_chan.red_gain * r + + r1 = TQMIN(65535, (int)(red_norm * (red_chan.red_gain * r + red_chan.green_gain * g + red_chan.blue_gain * b))); - g1 = QMIN(65535, (int)(green_norm * (green_chan.red_gain * r + + g1 = TQMIN(65535, (int)(green_norm * (green_chan.red_gain * r + green_chan.green_gain * g + green_chan.blue_gain * b))); - b1 = QMIN(65535, (int)(blue_norm * (blue_chan.red_gain * r + + b1 = TQMIN(65535, (int)(blue_norm * (blue_chan.red_gain * r + blue_chan.green_gain * g + blue_chan.blue_gain * b))); mptr[0] = b1; mptr[1] = g1; mptr[2] = r1; - mptr[3] = QMIN( (int)((r-g) / 38400.0 * 65535.0), 65535);; + mptr[3] = TQMIN( (int)((r-g) / 38400.0 * 65535.0), 65535);; } ptr += 4; @@ -514,19 +514,19 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) } } - // Now, we will blur only the transparency pixels from the mask. + // Now, we will blur only the transparency pixels from the tqmask. - Digikam::DImg mask2 = mask.copy(); + Digikam::DImg tqmask2 = tqmask.copy(); Digikam::DImgImageFilters filter; - filter.gaussianBlurImage(mask2.bits(), mask2.width(), mask2.height(), - mask2.sixteenBit(), m_smoothLevel->value()); + filter.gaussianBlurImage(tqmask2.bits(), tqmask2.width(), tqmask2.height(), + tqmask2.sixteenBit(), m_smoothLevel->value()); if (!selection.sixteenBit()) // 8 bits image. { - uchar* mptr = mask.bits(); - uchar* mptr2 = mask2.bits(); + uchar* mptr = tqmask.bits(); + uchar* mptr2 = tqmask2.bits(); - for (uint i = 0 ; i < mask2.width() * mask2.height() ; i++) + for (uint i = 0 ; i < tqmask2.width() * tqmask2.height() ; i++) { if (mptr2[3] < 255) { @@ -542,10 +542,10 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) } else // 16 bits image. { - unsigned short* mptr = (unsigned short*)mask.bits(); - unsigned short* mptr2 = (unsigned short*)mask2.bits(); + unsigned short* mptr = (unsigned short*)tqmask.bits(); + unsigned short* mptr2 = (unsigned short*)tqmask2.bits(); - for (uint i = 0 ; i < mask2.width() * mask2.height() ; i++) + for (uint i = 0 ; i < tqmask2.width() * tqmask2.height() ; i++) { if (mptr2[3] < 65535) { @@ -560,14 +560,14 @@ void ImageEffect_RedEye::redEyeFilter(Digikam::DImg& selection) } } - // - Perform pixels blending using alpha channel between the mask and the selection. + // - Perform pixels blending using alpha channel between the tqmask and the selection. Digikam::DColorComposer *composer = Digikam::DColorComposer::getComposer(Digikam::DColorComposer::PorterDuffSrcOver); - // NOTE: 'mask' is the Source image, 'selection' is the Destination image. + // NOTE: 'tqmask' is the Source image, 'selection' is the Destination image. - selection.bitBlendImage(composer, &mask, - 0, 0, mask.width(), mask.height(), + selection.bitBlendImage(composer, &tqmask, + 0, 0, tqmask.width(), tqmask.height(), 0, 0); } |