diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-11-22 18:41:30 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-11-22 20:55:03 +0900 |
commit | 5bed6e4a4c916a97f8fe4d1b07f7eecf4d733b90 (patch) | |
tree | f89cc49efc9ca1d0e1579ecb079ee7e7088ff8c8 /src/imageplugins/charcoal | |
parent | 0bfbf616d9c1fd7abb1bd02732389ab35e5f8771 (diff) | |
download | digikam-5bed6e4a4c916a97f8fe4d1b07f7eecf4d733b90.tar.gz digikam-5bed6e4a4c916a97f8fe4d1b07f7eecf4d733b90.zip |
Rename 'digikam' folder to 'src'
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit ee0d99607c14cb63d3ebdb3a970b508949fa8219)
Diffstat (limited to 'src/imageplugins/charcoal')
-rw-r--r-- | src/imageplugins/charcoal/Makefile.am | 34 | ||||
-rw-r--r-- | src/imageplugins/charcoal/charcoal.cpp | 249 | ||||
-rw-r--r-- | src/imageplugins/charcoal/charcoal.h | 56 | ||||
-rw-r--r-- | src/imageplugins/charcoal/charcoaltool.cpp | 202 | ||||
-rw-r--r-- | src/imageplugins/charcoal/charcoaltool.h | 82 | ||||
-rw-r--r-- | src/imageplugins/charcoal/digikamimageplugin_charcoal.desktop | 50 | ||||
-rw-r--r-- | src/imageplugins/charcoal/digikamimageplugin_charcoal_ui.rc | 20 | ||||
-rw-r--r-- | src/imageplugins/charcoal/imageeffect_charcoal.cpp | 193 | ||||
-rw-r--r-- | src/imageplugins/charcoal/imageeffect_charcoal.h | 69 | ||||
-rw-r--r-- | src/imageplugins/charcoal/imageplugin_charcoal.cpp | 72 | ||||
-rw-r--r-- | src/imageplugins/charcoal/imageplugin_charcoal.h | 57 |
11 files changed, 1084 insertions, 0 deletions
diff --git a/src/imageplugins/charcoal/Makefile.am b/src/imageplugins/charcoal/Makefile.am new file mode 100644 index 00000000..3d851deb --- /dev/null +++ b/src/imageplugins/charcoal/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_charcoal_la_SOURCES = imageplugin_charcoal.cpp \ + charcoaltool.cpp charcoal.cpp + +digikamimageplugin_charcoal_la_LIBADD = $(LIB_TDEPARTS) \ + $(top_builddir)/src/digikam/libdigikam.la + +digikamimageplugin_charcoal_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -ltdecore -ltdeui $(LIB_TQT) -ltdefx -lkdcraw -ltdeio + +kde_services_DATA = digikamimageplugin_charcoal.desktop + +kde_module_LTLIBRARIES = digikamimageplugin_charcoal.la + +rcdir = $(kde_datadir)/digikam +rc_DATA = digikamimageplugin_charcoal_ui.rc + diff --git a/src/imageplugins/charcoal/charcoal.cpp b/src/imageplugins/charcoal/charcoal.cpp new file mode 100644 index 00000000..a4c54a3c --- /dev/null +++ b/src/imageplugins/charcoal/charcoal.cpp @@ -0,0 +1,249 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2005-05-25 + * Description : Charcoal threaded image filter. + * + * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com> + * + * Original Charcoal algorithm copyright 2002 + * by Daniel M. Duley <mosfet@kde.org> from KImageEffect API. + * + * 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. + * + * ============================================================ */ + +#define SQ2PI 2.50662827463100024161235523934010416269302368164062 +#define Epsilon 1.0e-12 + +// C++ includes. + +#include <cmath> + +// Local includes. + +#include "ddebug.h" +#include "dimg.h" +#include "dimggaussianblur.h" +#include "dimgimagefilters.h" +#include "charcoal.h" + +namespace DigikamCharcoalImagesPlugin +{ + +Charcoal::Charcoal(Digikam::DImg *orgImage, TQObject *parent, double pencil, double smooth) + : Digikam::DImgThreadedFilter(orgImage, parent, "Charcoal") +{ + m_pencil = pencil; + m_smooth = smooth; + + initFilter(); +} + +void Charcoal::filterImage(void) +{ + if (m_orgImage.isNull()) + { + DWarning() << k_funcinfo << "No image data available!" + << endl; + return; + } + + if (m_pencil <= 0.0) + { + m_destImage = m_orgImage; + return; + } + + // -- Applying Edge effect ----------------------------------------------- + + long i=0; + int kernelWidth = getOptimalKernelWidth(m_pencil, m_smooth); + + if((int)m_orgImage.width() < kernelWidth) + { + DWarning() << k_funcinfo << "Image is smaller than radius!" + << endl; + return; + } + + double *kernel = new double[kernelWidth*kernelWidth]; + + if(!kernel) + { + DWarning() << k_funcinfo << "Unable to allocate memory!" + << endl; + return; + } + + for(i = 0 ; i < (kernelWidth*kernelWidth) ; i++) + kernel[i]=(-1.0); + + kernel[i/2]=kernelWidth*kernelWidth-1.0; + convolveImage(kernelWidth, kernel); + delete [] kernel; + + // -- Applying Gaussian blur effect --------------------------------------- + + Digikam::DImgGaussianBlur(this, m_destImage, m_destImage, 50, 60, (int)(m_smooth/10.0)); + + if (m_cancel) + return; + + // -- Applying strech contrast color effect ------------------------------- + + Digikam::DImgImageFilters().stretchContrastImage(m_destImage.bits(), m_destImage.width(), + m_destImage.height(), m_destImage.sixteenBit()); + postProgress( 70 ); + if (m_cancel) + return; + + // -- Inverting image color ----------------------------------------------- + + Digikam::DImgImageFilters().invertImage(m_destImage.bits(), m_destImage.width(), + m_destImage.height(), m_destImage.sixteenBit()); + postProgress( 80 ); + if (m_cancel) + return; + + // -- Convert to neutral black & white ------------------------------------ + + Digikam::DImgImageFilters().channelMixerImage( + m_destImage.bits(), m_destImage.width(), + m_destImage.height(), m_destImage.sixteenBit(), // Image data. + true, // Preserve luminosity. + true, // Monochrome. + 0.3, 0.59 , 0.11, // Red channel gains. + 0.0, 1.0, 0.0, // Green channel gains (not used). + 0.0, 0.0, 1.0); // Blue channel gains (not used). + postProgress( 90 ); + if (m_cancel) + return; +} + +bool Charcoal::convolveImage(const unsigned int order, const double *kernel) +{ + uint x, y; + int mx, my, sx, sy, mcx, mcy, progress; + long kernelWidth, i; + double red, green, blue, alpha, normalize=0.0; + double *k=0; + Digikam::DColor color; + + kernelWidth = order; + + if((kernelWidth % 2) == 0) + { + DWarning() << k_funcinfo << "Kernel width must be an odd number!" + << endl; + return(false); + } + + double *normal_kernel = new double[kernelWidth*kernelWidth]; + + if(!normal_kernel) + { + DWarning() << k_funcinfo << "Unable to allocate memory!" + << endl; + return(false); + } + + for(i=0 ; i < (kernelWidth*kernelWidth) ; i++) + normalize += kernel[i]; + + if(fabs(normalize) <= Epsilon) + normalize=1.0; + + normalize = 1.0/normalize; + + for(i=0 ; i < (kernelWidth*kernelWidth) ; i++) + normal_kernel[i] = normalize*kernel[i]; + + double maxClamp = m_destImage.sixteenBit() ? 16777215.0 : 65535.0; + + for(y=0 ; !m_cancel && (y < m_destImage.height()) ; y++) + { + sy = y-(kernelWidth/2); + + for(x=0 ; !m_cancel && (x < m_destImage.width()) ; x++) + { + k = normal_kernel; + red = green = blue = alpha = 0; + sy = y-(kernelWidth/2); + + for(mcy=0 ; !m_cancel && (mcy < kernelWidth) ; mcy++, sy++) + { + my = sy < 0 ? 0 : sy > (int)m_destImage.height()-1 ? m_destImage.height()-1 : sy; + sx = x+(-kernelWidth/2); + + for(mcx=0 ; !m_cancel && (mcx < kernelWidth) ; mcx++, sx++) + { + mx = sx < 0 ? 0 : sx > (int)m_destImage.width()-1 ? m_destImage.width()-1 : sx; + color = m_orgImage.getPixelColor(mx, my); + red += (*k)*(color.red() * 257.0); + green += (*k)*(color.green() * 257.0); + blue += (*k)*(color.blue() * 257.0); + alpha += (*k)*(color.alpha() * 257.0); + k++; + } + } + + red = red < 0.0 ? 0.0 : red > maxClamp ? maxClamp : red+0.5; + green = green < 0.0 ? 0.0 : green > maxClamp ? maxClamp : green+0.5; + blue = blue < 0.0 ? 0.0 : blue > maxClamp ? maxClamp : blue+0.5; + alpha = alpha < 0.0 ? 0.0 : alpha > maxClamp ? maxClamp : alpha+0.5; + + m_destImage.setPixelColor(x, y, Digikam::DColor((int)(red / 257UL), (int)(green / 257UL), + (int)(blue / 257UL), (int)(alpha / 257UL), + m_destImage.sixteenBit())); + } + + progress = (int)(((double)y * 50.0) / m_destImage.height()); + if ( progress%5 == 0 ) + postProgress( progress ); + } + + delete [] normal_kernel; + return(true); +} + +int Charcoal::getOptimalKernelWidth(double radius, double sigma) +{ + double normalize, value; + long kernelWidth; + long u; + + if(radius > 0.0) + return((int)(2.0*ceil(radius)+1.0)); + + for(kernelWidth=5; ;) + { + normalize=0.0; + + for(u=(-kernelWidth/2) ; u <= (kernelWidth/2) ; u++) + normalize += exp(-((double) u*u)/(2.0*sigma*sigma))/(SQ2PI*sigma); + + u = kernelWidth/2; + value = exp(-((double) u*u)/(2.0*sigma*sigma))/(SQ2PI*sigma)/normalize; + + if((long)(65535*value) <= 0) + break; + + kernelWidth+=2; + } + + return((int)kernelWidth-2); +} + +} // NameSpace DigikamCharcoalImagesPlugin diff --git a/src/imageplugins/charcoal/charcoal.h b/src/imageplugins/charcoal/charcoal.h new file mode 100644 index 00000000..2088ccc4 --- /dev/null +++ b/src/imageplugins/charcoal/charcoal.h @@ -0,0 +1,56 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2005-05-25 + * Description : Charcoal 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 CHARCOAL_H +#define CHARCOAL_H + +// Digikam includes. + +#include "dimgthreadedfilter.h" + +namespace DigikamCharcoalImagesPlugin +{ + +class Charcoal : public Digikam::DImgThreadedFilter +{ + +public: + + Charcoal(Digikam::DImg *orgImage, TQObject *parent=0, double pencil=5.0, double smooth=10.0); + ~Charcoal(){}; + +private: + + void filterImage(void); + bool convolveImage(const unsigned int order, const double *kernel); + int getOptimalKernelWidth(double radius, double sigma); + +private: + + double m_pencil; + double m_smooth; +}; + +} // NameSpace DigikamCharcoalImagesPlugin + +#endif /* CHARCOAL_H */ diff --git a/src/imageplugins/charcoal/charcoaltool.cpp b/src/imageplugins/charcoal/charcoaltool.cpp new file mode 100644 index 00000000..75ee22df --- /dev/null +++ b/src/imageplugins/charcoal/charcoaltool.cpp @@ -0,0 +1,202 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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> + +// KDE includes. + +#include <tdeconfig.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <kstandarddirs.h> + +// LibKDcraw includes. + +#include <libkdcraw/rnuminput.h> + +// Local includes. + +#include "daboutdata.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagepanelwidget.h" +#include "editortoolsettings.h" +#include "charcoal.h" +#include "charcoaltool.h" +#include "charcoaltool.moc" + +using namespace KDcrawIface; +using namespace Digikam; + +namespace DigikamCharcoalImagesPlugin +{ + +CharcoalTool::CharcoalTool(TQObject* parent) + : EditorToolThreaded(parent) +{ + setName("charcoal"); + setToolName(i18n("Charcoal")); + setToolIcon(SmallIcon("charcoaltool")); + + // ------------------------------------------------------------- + + m_gboxSettings = new EditorToolSettings(EditorToolSettings::Default| + EditorToolSettings::Ok| + EditorToolSettings::Cancel| + EditorToolSettings::Try, + EditorToolSettings::PanIcon); + TQGridLayout* grid = new TQGridLayout( m_gboxSettings->plainPage(), 4, 1); + TQLabel *label1 = new TQLabel(i18n("Pencil size:"), m_gboxSettings->plainPage()); + + m_pencilInput = new RIntNumInput(m_gboxSettings->plainPage()); + m_pencilInput->setRange(1, 100, 1); + m_pencilInput->setDefaultValue(5); + TQWhatsThis::add( m_pencilInput, i18n("<p>Set here the charcoal pencil size used to simulate the drawing.")); + + // ------------------------------------------------------------- + + TQLabel *label2 = new TQLabel(i18n("Smooth:"), m_gboxSettings->plainPage()); + + m_smoothInput = new RIntNumInput(m_gboxSettings->plainPage()); + m_smoothInput->setRange(1, 100, 1); + m_smoothInput->setDefaultValue(10); + TQWhatsThis::add( m_smoothInput, i18n("<p>This value controls the smoothing effect of the pencil " + "under the canvas.")); + + grid->addMultiCellWidget(label1, 0, 0, 0, 1); + grid->addMultiCellWidget(m_pencilInput, 1, 1, 0, 1); + grid->addMultiCellWidget(label2, 2, 2, 0, 1); + grid->addMultiCellWidget(m_smoothInput, 3, 3, 0, 1); + grid->setRowStretch(4, 10); + grid->setMargin(m_gboxSettings->spacingHint()); + grid->setSpacing(m_gboxSettings->spacingHint()); + + setToolSettings(m_gboxSettings); + + // ------------------------------------------------------------- + + m_previewWidget = new ImagePanelWidget(470, 350, "charcoal Tool", m_gboxSettings->panIconView()); + + setToolView(m_previewWidget); + init(); + + // ------------------------------------------------------------- + + connect(m_pencilInput, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(slotTimer())); + + connect(m_smoothInput, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(slotTimer())); +} + +CharcoalTool::~CharcoalTool() +{ +} + +void CharcoalTool::renderingFinished() +{ + m_pencilInput->setEnabled(true); + m_smoothInput->setEnabled(true); +} + +void CharcoalTool::readSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("charcoal Tool"); + m_pencilInput->blockSignals(true); + m_smoothInput->blockSignals(true); + + m_pencilInput->setValue(config->readNumEntry("PencilAjustment", m_pencilInput->defaultValue())); + m_smoothInput->setValue(config->readNumEntry("SmoothAjustment", m_smoothInput->defaultValue())); + + m_pencilInput->blockSignals(false); + m_smoothInput->blockSignals(false); +} + +void CharcoalTool::writeSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("charcoal Tool"); + config->writeEntry("PencilAjustment", m_pencilInput->value()); + config->writeEntry("SmoothAjustment", m_smoothInput->value()); + m_previewWidget->writeSettings(); + config->sync(); +} + +void CharcoalTool::slotResetSettings() +{ + m_pencilInput->blockSignals(true); + m_smoothInput->blockSignals(true); + + m_pencilInput->slotReset(); + m_smoothInput->slotReset(); + + m_pencilInput->blockSignals(false); + m_smoothInput->blockSignals(false); +} + +void CharcoalTool::prepareEffect() +{ + m_pencilInput->setEnabled(false); + m_smoothInput->setEnabled(false); + + double pencil = (double)m_pencilInput->value()/10.0; + double smooth = (double)m_smoothInput->value(); + + DImg image = m_previewWidget->getOriginalRegionImage(); + + setFilter(dynamic_cast<DImgThreadedFilter*>(new Charcoal(&image, this, pencil, smooth))); +} + +void CharcoalTool::prepareFinal() +{ + m_pencilInput->setEnabled(false); + m_smoothInput->setEnabled(false); + + double pencil = (double)m_pencilInput->value()/10.0; + double smooth = (double)m_smoothInput->value(); + + ImageIface iface(0, 0); + setFilter(dynamic_cast<DImgThreadedFilter*>(new Charcoal(iface.getOriginalImg(), this, pencil, smooth))); +} + +void CharcoalTool::putPreviewData() +{ + m_previewWidget->setPreviewImage(filter()->getTargetImage()); +} + +void CharcoalTool::putFinalData() +{ + ImageIface iface(0, 0); + iface.putOriginalImage(i18n("Charcoal"), filter()->getTargetImage().bits()); +} + +} // NameSpace DigikamCharcoalImagesPlugin diff --git a/src/imageplugins/charcoal/charcoaltool.h b/src/imageplugins/charcoal/charcoaltool.h new file mode 100644 index 00000000..5833dd06 --- /dev/null +++ b/src/imageplugins/charcoal/charcoaltool.h @@ -0,0 +1,82 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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 CHARCOALTOOL_H +#define CHARCOALTOOL_H + +// Local includes. + +#include "editortool.h" + +namespace KDcrawIface +{ +class RIntNumInput; +} + +namespace Digikam +{ +class EditorToolSettings; +class ImagePanelWidget; +} + +namespace DigikamCharcoalImagesPlugin +{ + +class CharcoalTool : public Digikam::EditorToolThreaded +{ + TQ_OBJECT + + +public: + + CharcoalTool(TQObject* parent); + ~CharcoalTool(); + +private slots: + + void slotResetSettings(); + +private: + + void readSettings(); + void writeSettings(); + void prepareEffect(); + void prepareFinal(); + void putPreviewData(); + void putFinalData(); + void renderingFinished(); + +private: + + KDcrawIface::RIntNumInput *m_pencilInput; + KDcrawIface::RIntNumInput *m_smoothInput; + + Digikam::ImagePanelWidget *m_previewWidget; + + Digikam::EditorToolSettings *m_gboxSettings; +}; + +} // NameSpace DigikamCharcoalImagesPlugin + +#endif /* CHARCOALTOOL_H */ diff --git a/src/imageplugins/charcoal/digikamimageplugin_charcoal.desktop b/src/imageplugins/charcoal/digikamimageplugin_charcoal.desktop new file mode 100644 index 00000000..e8957bbf --- /dev/null +++ b/src/imageplugins/charcoal/digikamimageplugin_charcoal.desktop @@ -0,0 +1,50 @@ +[Desktop Entry] +Name=ImagePlugin_Charcoal +Name[bg]=Приставка за снимки - Въглен +Name[da]=Billedplugin_Kultegning +Name[el]=ΠρόσθετοΕικόνας_Κάρβουνο +Name[fi]=Hiilipiirros +Name[hr]=Crtež ugljenom +Name[it]=PluginImmagini_Carboncino +Name[nl]=Afbeeldingsplugin_Houtskool +Name[sr]=Угљен +Name[sr@Latn]=Ugljen +Name[sv]=Insticksprogram för kolteckning +Name[tr]=ResimEklentisi_Karakalem +Name[xx]=xxImagePlugin_Charcoalxx +Type=Service +X-TDE-ServiceTypes=Digikam/ImagePlugin +Encoding=UTF-8 +Comment=Charcoal drawing image effect plugin for digiKam +Comment[bg]=Приставка на digiKam за наподобяване на рисуване с въглен върху снимки +Comment[ca]=Connector pel digiKam d'efecte d'imatge de dibuix al carbonet +Comment[da]=Plugin til kultegningseffekt på billeder i Digikam +Comment[de]=digiKam-Modul zum Erzeugen eines Kohlezeichnung-Effekts +Comment[el]=Πρόσθετο εφέ σχεδίασης με κάρβουνο για το digiKam +Comment[es]=Plugin para digiKam con efectos de dibujo a carboncillo +Comment[et]=DigiKami söejoonistuse pildiefektiplugin +Comment[fa]=وصلۀ جلوۀ تصویر ترسیم Charcoal برای digiKam +Comment[fi]=Jäljittelee hiiliviivapiirrosta +Comment[gl]=Un plugin de digiKam para o efeito de imaxe debuxada ao carbón +Comment[hr]=digiKam dodatak za efekt crtanja ugljenom +Comment[is]=Íforrit fyrir digiKam sem líkir eftir viðarkolateikningu +Comment[it]=Plugin di effetto di disegno dell'immagine con carboncino per digiKam +Comment[ja]=digiKam 木炭画効果プラグイン +Comment[nds]=digiKam-Moduul för Kahlteken-Effekten +Comment[nl]=Digikam-plugin voor houtskooltekeningen +Comment[pa]=ਡਿਜ਼ੀਕੈਮ ਲਈ ਚਾਰਕੋਲ ਡਰਾਇੰਗ ਚਿੱਤਰ ਪਰਭਾਵ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka do programu digiKam imitująca szkice węglem +Comment[pt]=Um 'plugin' do digiKam para o efeito de imagem de desenho a carvão +Comment[pt_BR]=Plugin de efeito de carvão para o digiKam +Comment[ru]=Модуль изображения картинки углем для digiKam +Comment[sk]=digiKam plugin pre efekt kreslenia kriedou +Comment[sr]=Прикључак ефекта цртежа угљеном за digiKam +Comment[sr@Latn]=Priključak efekta crteža ugljenom za digiKam +Comment[sv]=Digikam insticksprogram för kolteckningsbildeffekt +Comment[tr]=digiKam için karakalem resim etkisi eklentisi +Comment[uk]=Втулок створення ефекту малювання вугільним олівцем для digiKam +Comment[vi]=Phần bổ sung hiệu ứng vẽ ảnh than gỗ cho digiKam +Comment[xx]=xxCharcoal drawing image effect plugin for digiKamxx + +X-TDE-Library=digikamimageplugin_charcoal +author=Gilles Caulier, caulier dot gilles at gmail dot com diff --git a/src/imageplugins/charcoal/digikamimageplugin_charcoal_ui.rc b/src/imageplugins/charcoal/digikamimageplugin_charcoal_ui.rc new file mode 100644 index 00000000..92ab4752 --- /dev/null +++ b/src/imageplugins/charcoal/digikamimageplugin_charcoal_ui.rc @@ -0,0 +1,20 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui version="6" name="digikamimageplugin_charcoal" > + + <MenuBar> + + <Menu name="Filters" ><text>F&ilters</text> + <Action name="imageplugin_charcoal" /> + </Menu> + + </MenuBar> + + <ToolBar name="ToolBar" > + <text>Main Toolbar</text> + </ToolBar> + + <ActionProperties> + <Action shortcut="" name="imageplugin_charcoal" /> + </ActionProperties> + +</kpartgui> diff --git a/src/imageplugins/charcoal/imageeffect_charcoal.cpp b/src/imageplugins/charcoal/imageeffect_charcoal.cpp new file mode 100644 index 00000000..67a0269d --- /dev/null +++ b/src/imageplugins/charcoal/imageeffect_charcoal.cpp @@ -0,0 +1,193 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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> + +// KDE includes. + +#include <tdeconfig.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <knuminput.h> +#include <kstandarddirs.h> + +// Local includes. + +#include "version.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "charcoal.h" +#include "imageeffect_charcoal.h" +#include "imageeffect_charcoal.moc" + +namespace DigikamCharcoalImagesPlugin +{ + +ImageEffect_Charcoal::ImageEffect_Charcoal(TQWidget* parent) + : Digikam::CtrlPanelDlg(parent, i18n("Charcoal Drawing"), + "charcoal", false, false, true, + Digikam::ImagePannelWidget::SeparateViewAll) +{ + TQString whatsThis; + + TDEAboutData* about = new TDEAboutData("digikam", + I18N_NOOP("Charcoal Drawing"), + digikam_version, + I18N_NOOP("A digiKam charcoal drawing image effect plugin."), + 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); + + // ------------------------------------------------------------- + + TQWidget *gboxSettings = new TQWidget(m_imagePreviewWidget); + TQGridLayout* gridSettings = new TQGridLayout( gboxSettings, 3, 1, 0, spacingHint()); + TQLabel *label1 = new TQLabel(i18n("Pencil size:"), gboxSettings); + + m_pencilInput = new KIntNumInput(gboxSettings); + m_pencilInput->setRange(1, 100, 1, true); + m_pencilInput->setValue(5); + TQWhatsThis::add( m_pencilInput, i18n("<p>Set here the charcoal pencil size used to simulate the drawing.")); + + gridSettings->addMultiCellWidget(label1, 0, 0, 0, 1); + gridSettings->addMultiCellWidget(m_pencilInput, 1, 1, 0, 1); + + // ------------------------------------------------------------- + + TQLabel *label2 = new TQLabel(i18n("Smooth:"), gboxSettings); + + m_smoothInput = new KIntNumInput(gboxSettings); + m_smoothInput->setRange(1, 100, 1, true); + m_smoothInput->setValue(10); + TQWhatsThis::add( m_smoothInput, i18n("<p>This value controls the smoothing effect of the pencil " + "under the canvas.")); + + gridSettings->addMultiCellWidget(label2, 2, 2, 0, 1); + gridSettings->addMultiCellWidget(m_smoothInput, 3, 3, 0, 1); + + m_imagePreviewWidget->setUserAreaWidget(gboxSettings); + + // ------------------------------------------------------------- + + connect(m_pencilInput, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(slotTimer())); + + connect(m_smoothInput, TQ_SIGNAL(valueChanged(int)), + this, TQ_SLOT(slotTimer())); +} + +ImageEffect_Charcoal::~ImageEffect_Charcoal() +{ +} + +void ImageEffect_Charcoal::renderingFinished() +{ + m_pencilInput->setEnabled(true); + m_smoothInput->setEnabled(true); +} + +void ImageEffect_Charcoal::readUserSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("charcoal Tool Dialog"); + m_pencilInput->blockSignals(true); + m_smoothInput->blockSignals(true); + m_pencilInput->setValue(config->readNumEntry("PencilAjustment", 5)); + m_smoothInput->setValue(config->readNumEntry("SmoothAjustment", 10)); + m_pencilInput->blockSignals(false); + m_smoothInput->blockSignals(false); +} + +void ImageEffect_Charcoal::writeUserSettings() +{ + TDEConfig* config = kapp->config(); + config->setGroup("charcoal Tool Dialog"); + config->writeEntry("PencilAjustment", m_pencilInput->value()); + config->writeEntry("SmoothAjustment", m_smoothInput->value()); + config->sync(); +} + +void ImageEffect_Charcoal::resetValues() +{ + m_pencilInput->blockSignals(true); + m_smoothInput->blockSignals(true); + m_pencilInput->setValue(5); + m_smoothInput->setValue(10); + m_pencilInput->blockSignals(false); + m_smoothInput->blockSignals(false); +} + +void ImageEffect_Charcoal::prepareEffect() +{ + m_pencilInput->setEnabled(false); + m_smoothInput->setEnabled(false); + + double pencil = (double)m_pencilInput->value()/10.0; + double smooth = (double)m_smoothInput->value(); + + Digikam::DImg image = m_imagePreviewWidget->getOriginalRegionImage(); + + m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>(new Charcoal(&image, this, pencil, smooth)); +} + +void ImageEffect_Charcoal::prepareFinal() +{ + m_pencilInput->setEnabled(false); + m_smoothInput->setEnabled(false); + + double pencil = (double)m_pencilInput->value()/10.0; + double smooth = (double)m_smoothInput->value(); + + Digikam::ImageIface iface(0, 0); + m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>(new Charcoal(iface.getOriginalImg(), + this, pencil, smooth)); +} + +void ImageEffect_Charcoal::putPreviewData(void) +{ + m_imagePreviewWidget->setPreviewImage(m_threadedFilter->getTargetImage()); +} + +void ImageEffect_Charcoal::putFinalData(void) +{ + Digikam::ImageIface iface(0, 0); + iface.putOriginalImage(i18n("Charcoal"), m_threadedFilter->getTargetImage().bits()); +} + +} // NameSpace DigikamCharcoalImagesPlugin + diff --git a/src/imageplugins/charcoal/imageeffect_charcoal.h b/src/imageplugins/charcoal/imageeffect_charcoal.h new file mode 100644 index 00000000..31916ecc --- /dev/null +++ b/src/imageplugins/charcoal/imageeffect_charcoal.h @@ -0,0 +1,69 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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 IMAGEEFFECT_CHARCOAL_H +#define IMAGEEFFECT_CHARCOAL_H + +// Local includes. + +#include "ctrlpaneldlg.h" + +class KIntNumInput; + +namespace DigikamCharcoalImagesPlugin +{ + +class ImageEffect_Charcoal : public Digikam::CtrlPanelDlg +{ + TQ_OBJECT + + +public: + + ImageEffect_Charcoal(TQWidget* parent); + ~ImageEffect_Charcoal(); + +private slots: + + void readUserSettings(); + +private: + + void writeUserSettings(); + void resetValues(); + void prepareEffect(); + void prepareFinal(); + void putPreviewData(); + void putFinalData(); + void renderingFinished(); + +private: + + KIntNumInput *m_pencilInput; + KIntNumInput *m_smoothInput; +}; + +} // NameSpace DigikamCharcoalImagesPlugin + +#endif /* IMAGEEFFECT_CHARCOAL_H */ diff --git a/src/imageplugins/charcoal/imageplugin_charcoal.cpp b/src/imageplugins/charcoal/imageplugin_charcoal.cpp new file mode 100644 index 00000000..ae28e7ca --- /dev/null +++ b/src/imageplugins/charcoal/imageplugin_charcoal.cpp @@ -0,0 +1,72 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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> +#include <tdeapplication.h> + +// Local includes. + +#include "ddebug.h" +#include "charcoaltool.h" +#include "imageplugin_charcoal.h" +#include "imageplugin_charcoal.moc" + +using namespace DigikamCharcoalImagesPlugin; + +K_EXPORT_COMPONENT_FACTORY(digikamimageplugin_charcoal, + KGenericFactory<ImagePlugin_Charcoal>("digikamimageplugin_charcoal")); + +ImagePlugin_Charcoal::ImagePlugin_Charcoal(TQObject *parent, const char*, + const TQStringList &) + : Digikam::ImagePlugin(parent, "ImagePlugin_Charcoal") +{ + m_charcoalAction = new TDEAction(i18n("Charcoal Drawing..."), "charcoaltool", 0, + this, TQ_SLOT(slotCharcoal()), + actionCollection(), "imageplugin_charcoal"); + + setXMLFile( "digikamimageplugin_charcoal_ui.rc" ); + + DDebug() << "ImagePlugin_Charcoal plugin loaded" << endl; +} + +ImagePlugin_Charcoal::~ImagePlugin_Charcoal() +{ +} + +void ImagePlugin_Charcoal::setEnabledActions(bool enable) +{ + m_charcoalAction->setEnabled(enable); +} + +void ImagePlugin_Charcoal::slotCharcoal() +{ + CharcoalTool *tool = new CharcoalTool(this); + loadTool(tool); +} diff --git a/src/imageplugins/charcoal/imageplugin_charcoal.h b/src/imageplugins/charcoal/imageplugin_charcoal.h new file mode 100644 index 00000000..c642087a --- /dev/null +++ b/src/imageplugins/charcoal/imageplugin_charcoal.h @@ -0,0 +1,57 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date : 2004-08-26 + * Description : a digikam image editor plugin to + * simulate charcoal drawing. + * + * 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_CHARCOAL_H +#define IMAGEPLUGIN_CHARCOAL_H + +// Digikam includes. + +#include "imageplugin.h" +#include "digikam_export.h" + +class TDEAction; + +class DIGIKAMIMAGEPLUGINS_EXPORT ImagePlugin_Charcoal : public Digikam::ImagePlugin +{ + TQ_OBJECT + + +public: + + ImagePlugin_Charcoal(TQObject *parent, const char* name, + const TQStringList &args); + ~ImagePlugin_Charcoal(); + + void setEnabledActions(bool enable); + +private slots: + + void slotCharcoal(); + +private: + + TDEAction *m_charcoalAction; +}; + +#endif /* IMAGEPLUGIN_CHARCOAL_H */ |