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/texture/imageeffect_texture.cpp | |
| parent | 0bfbf616d9c1fd7abb1bd02732389ab35e5f8771 (diff) | |
| download | digikam-5bed6e4a.tar.gz digikam-5bed6e4a.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/texture/imageeffect_texture.cpp')
| -rw-r--r-- | src/imageplugins/texture/imageeffect_texture.cpp | 291 | 
1 files changed, 291 insertions, 0 deletions
| diff --git a/src/imageplugins/texture/imageeffect_texture.cpp b/src/imageplugins/texture/imageeffect_texture.cpp new file mode 100644 index 00000000..5f5d7e9f --- /dev/null +++ b/src/imageplugins/texture/imageeffect_texture.cpp @@ -0,0 +1,291 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-03-10 + * Description : a plugin to apply texture over an image + *  + * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com> + * Copyright (C) 2006-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> + *  + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) + * any later version. + *  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + *  + * ============================================================ */ + +// TQt includes. + +#include <tqlabel.h> +#include <tqwhatsthis.h> +#include <tqlayout.h> +#include <tqcombobox.h> +#include <tqimage.h> + +// KDE includes. + +#include <tdeconfig.h> +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <kstandarddirs.h> +#include <knuminput.h> + +// Local includes. + +#include "version.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "texture.h" +#include "imageeffect_texture.h" +#include "imageeffect_texture.moc" + +namespace DigikamTextureImagesPlugin +{ + +ImageEffect_Texture::ImageEffect_Texture(TQWidget* parent) +                   : Digikam::CtrlPanelDlg(parent, i18n("Apply Texture"),  +                                           "texture", false, false, true,  +                                           Digikam::ImagePannelWidget::SeparateViewAll) +{ +    TQString whatsThis; + +    TDEAboutData* about = new TDEAboutData("digikam", +                                       I18N_NOOP("Apply Texture"),  +                                       digikam_version, +                                       I18N_NOOP("A digiKam image plugin to apply a decorative " +                                       "texture to an image."), +                                       TDEAboutData::License_GPL, +                                       "(c) 2005, Gilles Caulier\n" +                                       "(c) 2006-2008, Gilles Caulier and Marcel Wiesweg", +                                       0, +                                       "http://www.digikam.org"); + +    about->addAuthor("Gilles Caulier", I18N_NOOP("Author and maintainer"), +                     "caulier dot gilles at gmail dot com"); + +    about->addAuthor("Marcel Wiesweg", I18N_NOOP("Developer"), +                     "marcel dot wiesweg at gmx dot de"); + +    setAboutData(about); + +    // ------------------------------------------------------------- + +    TQWidget *gboxSettings     = new TQWidget(m_imagePreviewWidget); +    TQGridLayout* gridSettings = new TQGridLayout( gboxSettings, 2, 1, 0, spacingHint()); +    TQLabel *label1 = new TQLabel(i18n("Type:"), gboxSettings); + +    m_textureType = new TQComboBox( false, gboxSettings ); +    m_textureType->insertItem( i18n("Paper") ); +    m_textureType->insertItem( i18n("Paper 2") ); +    m_textureType->insertItem( i18n("Fabric") ); +    m_textureType->insertItem( i18n("Burlap") ); +    m_textureType->insertItem( i18n("Bricks") ); +    m_textureType->insertItem( i18n("Bricks 2") ); +    m_textureType->insertItem( i18n("Canvas") ); +    m_textureType->insertItem( i18n("Marble") ); +    m_textureType->insertItem( i18n("Marble 2") ); +    m_textureType->insertItem( i18n("Blue Jean") ); +    m_textureType->insertItem( i18n("Cell Wood") ); +    m_textureType->insertItem( i18n("Metal Wire") ); +    m_textureType->insertItem( i18n("Modern") ); +    m_textureType->insertItem( i18n("Wall") ); +    m_textureType->insertItem( i18n("Moss") ); +    m_textureType->insertItem( i18n("Stone") ); +    TQWhatsThis::add( m_textureType, i18n("<p>Set here the texture type to apply to the image.")); +     +    gridSettings->addMultiCellWidget(label1, 0, 0, 0, 0); +    gridSettings->addMultiCellWidget(m_textureType, 0, 0, 1, 1); +     +    // ------------------------------------------------------------- +     +    TQLabel *label2 = new TQLabel(i18n("Relief:"), gboxSettings); +     +    m_blendGain = new KIntNumInput(gboxSettings); +    m_blendGain->setRange(1, 255, 1, true);   +    m_blendGain->setValue(200); +    TQWhatsThis::add( m_blendGain, i18n("<p>Set here the relief gain used to merge texture and image.")); + +    gridSettings->addMultiCellWidget(label2, 1, 1, 0, 1); +    gridSettings->addMultiCellWidget(m_blendGain, 2, 2, 0, 1); +     +    m_imagePreviewWidget->setUserAreaWidget(gboxSettings); +     +    // ------------------------------------------------------------- +         +    connect(m_textureType, TQ_SIGNAL(activated(int)), +            this, TQ_SLOT(slotEffect())); +             +    connect(m_blendGain, TQ_SIGNAL(valueChanged(int)), +            this, TQ_SLOT(slotTimer()));                         +} + +ImageEffect_Texture::~ImageEffect_Texture() +{ +} + +void ImageEffect_Texture::renderingFinished() +{ +    m_textureType->setEnabled(true); +    m_blendGain->setEnabled(true); +} + +void ImageEffect_Texture::readUserSettings() +{ +    TDEConfig* config = kapp->config(); +    config->setGroup("texture Tool Dialog"); +    m_textureType->blockSignals(true); +    m_blendGain->blockSignals(true); +    m_textureType->setCurrentItem(config->readNumEntry("TextureType", PaperTexture)); +    m_blendGain->setValue(config->readNumEntry("BlendGain", 200)); +    m_textureType->blockSignals(false); +    m_blendGain->blockSignals(false); +} + +void ImageEffect_Texture::writeUserSettings() +{ +    TDEConfig* config = kapp->config(); +    config->setGroup("texture Tool Dialog"); +    config->writeEntry("TextureType", m_textureType->currentItem()); +    config->writeEntry("BlendGain", m_blendGain->value()); +    config->sync(); +} + +void ImageEffect_Texture::resetValues() +{ +    m_textureType->blockSignals(true); +    m_blendGain->blockSignals(true); +    m_textureType->setCurrentItem(PaperTexture);     +    m_blendGain->setValue(200); +    m_textureType->blockSignals(false); +    m_blendGain->blockSignals(false); +}  + +void ImageEffect_Texture::prepareEffect() +{ +    m_textureType->setEnabled(false); +    m_blendGain->setEnabled(false); + +    Digikam::DImg image = m_imagePreviewWidget->getOriginalRegionImage(); +    TQString texture = getTexturePath( m_textureType->currentItem() ); + +    int b = 255 - m_blendGain->value(); + +    m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>( +                       new Texture(&image, this, b, texture)); +} + +void ImageEffect_Texture::prepareFinal() +{ +    m_textureType->setEnabled(false); +    m_blendGain->setEnabled(false); + +    int b = 255 - m_blendGain->value(); + +    Digikam::ImageIface iface(0, 0); +    TQString texture = getTexturePath( m_textureType->currentItem() ); + +    m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>( +                       new Texture(iface.getOriginalImg(), this, b, texture)); +} + +void ImageEffect_Texture::putPreviewData(void) +{ +    m_imagePreviewWidget->setPreviewImage(m_threadedFilter->getTargetImage()); +} + +void ImageEffect_Texture::putFinalData(void) +{ +    Digikam::ImageIface iface(0, 0); +    iface.putOriginalImage(i18n("Texture"), m_threadedFilter->getTargetImage().bits()); +} + +TQString ImageEffect_Texture::getTexturePath(int texture) +{ +    TQString pattern; +     +    switch (texture) +       { +       case PaperTexture:  +          pattern = "paper-texture"; +          break; +           +       case Paper2Texture:  +          pattern = "paper2-texture"; +          break; + +       case FabricTexture:  +          pattern = "fabric-texture"; +          break; +        +       case BurlapTexture: +          pattern = "burlap-texture"; +          break; + +       case BricksTexture: +          pattern = "bricks-texture"; +          break; + +       case Bricks2Texture: +          pattern = "bricks2-texture"; +          break; +                            +       case CanvasTexture: +          pattern = "canvas-texture"; +          break; +                            +       case MarbleTexture: +          pattern = "marble-texture"; +          break; +                            +       case Marble2Texture: +          pattern = "marble2-texture"; +          break; + +       case BlueJeanTexture: +          pattern = "bluejean-texture"; +          break; +                                      +       case CellWoodTexture: +          pattern = "cellwood-texture"; +          break; +        +       case MetalWireTexture: +          pattern = "metalwire-texture"; +          break; +        +       case ModernTexture: +          pattern = "modern-texture"; +          break; +        +       case WallTexture: +          pattern = "wall-texture"; +          break; + +       case MossTexture: +          pattern = "moss-texture"; +          break; +                     +       case StoneTexture: +          pattern = "stone-texture"; +          break; +       } +     +    TDEGlobal::dirs()->addResourceType(pattern.ascii(), TDEGlobal::dirs()->kde_default("data") + +                                     "digikam/data"); +    return (TDEGlobal::dirs()->findResourceDir(pattern.ascii(), pattern + ".png") + pattern + ".png" ); +} +     +}  // NameSpace DigikamTextureImagesPlugin + | 
