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/freerotation | |
| 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/freerotation')
11 files changed, 1395 insertions, 0 deletions
| diff --git a/src/imageplugins/freerotation/Makefile.am b/src/imageplugins/freerotation/Makefile.am new file mode 100644 index 00000000..e2b67283 --- /dev/null +++ b/src/imageplugins/freerotation/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_freerotation_la_SOURCES = imageplugin_freerotation.cpp \ +	                                         freerotationtool.cpp freerotation.cpp  + +digikamimageplugin_freerotation_la_LIBADD = $(LIB_TDEPARTS) \ +	                                        $(top_builddir)/src/digikam/libdigikam.la  + +digikamimageplugin_freerotation_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -ltdecore -ltdeui $(LIB_TQT) -ltdefx -lkdcraw -ltdeio + +kde_services_DATA = digikamimageplugin_freerotation.desktop + +kde_module_LTLIBRARIES = digikamimageplugin_freerotation.la + +rcdir = $(kde_datadir)/digikam +rc_DATA = digikamimageplugin_freerotation_ui.rc + diff --git a/src/imageplugins/freerotation/digikamimageplugin_freerotation.desktop b/src/imageplugins/freerotation/digikamimageplugin_freerotation.desktop new file mode 100644 index 00000000..47659a0d --- /dev/null +++ b/src/imageplugins/freerotation/digikamimageplugin_freerotation.desktop @@ -0,0 +1,51 @@ +[Desktop Entry] +Name=ImagePlugin_FreeRotation +Name[bg]=Приставка за снимки - Свободно завъртане +Name[da]=Billedplugin_Fri rotation +Name[el]=ΠρόσθετοΕικόνας_ΕλεύθερηΠεριστροφή +Name[fi]=Kierto +Name[hr]=Slobodno obrtanje +Name[it]=PluginImmagini_RotazioneLibera +Name[nl]=Afbeeldingsplugin_VrijeRotatie +Name[sr]=Слободно окретање +Name[sr@Latn]=Slobodno okretanje +Name[sv]=Insticksprogram för bildrotation +Name[tr]=ResimEklentisi_SerbestDöndürme +Name[xx]=xxImagePlugin_FreeRotationxx + +Type=Service +X-TDE-ServiceTypes=Digikam/ImagePlugin +Encoding=UTF-8 +Comment=Free rotation plugin for digiKam +Comment[bg]=Приставка на digiKam за свободно завъртане на снимки +Comment[ca]=Connector pel digiKam de gir lliure +Comment[da]=Plugin til fri rotation af billeder til Digikam +Comment[de]=digiKam-Modul zur freien Drehung von Bildern +Comment[el]=Πρόσθετο ελεύθερης περιστροφής για το digiKam +Comment[es]=Plugin para digiKam de rotación +Comment[et]=DigiKami pildi vaba pööramise plugin +Comment[fa]=وصلۀ چرخش آزاد برای digiKam +Comment[fi]=Kiertää kuvaa vapaasti määritettävien asteiden verran +Comment[gl]=Un plugin de digiKam para a rotazón libre da imaxe +Comment[hr]=digiKam dodatak za slobodno obrtanje +Comment[is]=Íforrit fyrir digiKam sem leyfir frjálsan snúning mynda +Comment[it]=Plugin per la rotazione libera per digiKam +Comment[ja]=digiKam 画像自由回転プラグイン +Comment[nds]=digiKam-Moduul för't fre'e Dreihen +Comment[nl]=Digikam-plugin voor vrije rotatie +Comment[pa]=ਡਿਜ਼ੀਕੈਮ ਲਈ ਮੁਕਤ ਘੁੰਮਾਉਣ ਵਾਲੀ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka do programu digiKam umożliwiająca swobodny obrót obrazu +Comment[pt]=Um 'plugin' do digiKam para a rotação livre da imagem +Comment[pt_BR]=Plugin de Rotação Livre +Comment[ru]=Модуль свободного вращения для digiKam +Comment[sk]=digiKam plugin voľného otáčania +Comment[sr]=digiKam-ов прикључак за слободно окретање +Comment[sr@Latn]=digiKam-ov priključak za slobodno okretanje +Comment[sv]=Digikam insticksprogram för bildrotation +Comment[tr]=digiKam için serbest döndürme eklentisi +Comment[uk]=Втулок вільного обертання для digiKam +Comment[vi]=Phần bổ sung xoay tự do cho digiKam +Comment[xx]=xxFree rotation plugin for digiKamxx + +X-TDE-Library=digikamimageplugin_freerotation +author=Gilles Caulier, caulier dot gilles at gmail dot com diff --git a/src/imageplugins/freerotation/digikamimageplugin_freerotation_ui.rc b/src/imageplugins/freerotation/digikamimageplugin_freerotation_ui.rc new file mode 100644 index 00000000..fbbf9605 --- /dev/null +++ b/src/imageplugins/freerotation/digikamimageplugin_freerotation_ui.rc @@ -0,0 +1,20 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui version="4" name="digikamimageplugin_freerotation" > + + <MenuBar> + +  <Menu name="Transform" ><text>Tra&nsform</text> +   <Action name="imageplugin_freerotation" />  +  </Menu> + + </MenuBar> +  + <ToolBar name="ToolBar" > +  <text>Main Toolbar</text> + </ToolBar> +  + <ActionProperties> +  <Action shortcut="" name="imageplugin_freerotation" /> + </ActionProperties> + +</kpartgui> diff --git a/src/imageplugins/freerotation/freerotation.cpp b/src/imageplugins/freerotation/freerotation.cpp new file mode 100644 index 00000000..3f8803d5 --- /dev/null +++ b/src/imageplugins/freerotation/freerotation.cpp @@ -0,0 +1,263 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-07-18 + * Description : Free rotation threaded image filter. + *  + * Copyright (C) 2004-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. + *  + * ============================================================ */ + +// Degrees to radian convertion coeff (PI/180). To optimize computation. +#define DEG2RAD 0.017453292519943 + +// C++ includes. + +#include <cmath> +#include <cstdlib> + +// Local includes. + +#include "dimg.h" +#include "dimgimagefilters.h" +#include "freerotation.h" + +namespace DigikamFreeRotationImagesPlugin +{ + +FreeRotation::FreeRotation(Digikam::DImg *orgImage, TQObject *parent, double angle, bool antialiasing, +                           int autoCrop, TQColor backgroundColor, int orgW, int orgH) +            : Digikam::DImgThreadedFilter(orgImage, parent, "FreeRotation") +{  +    m_angle           = angle; +    m_orgW            = orgW; +    m_orgH            = orgH; +    m_antiAlias       = antialiasing; +    m_autoCrop        = autoCrop; +    m_backgroundColor = backgroundColor; +         +    initFilter(); +} + +void FreeRotation::filterImage(void) +{ +    int          progress; +    int w, h, nw, nh, j, i = 0; +    int          nNewHeight, nNewWidth; +    int          nhdx, nhdy, nhsx, nhsy; +    double       lfSin, lfCos, lfx, lfy; +     +    int nWidth  = m_orgImage.width(); +    int nHeight = m_orgImage.height(); +     +    uchar *pBits            = m_orgImage.bits(); +    unsigned short *pBits16 = (unsigned short*)m_orgImage.bits(); +     +    // first of all, we need to calcule the sin and cos of the given angle +     +    lfSin = sin (m_angle * -DEG2RAD); +    lfCos = cos (m_angle * -DEG2RAD); + +    // now, we have to calc the new size for the destination image +     +    if ((lfSin * lfCos) < 0) +    { +        nNewWidth  = ROUND (fabs (nWidth * lfCos - nHeight * lfSin)); +        nNewHeight = ROUND (fabs (nWidth * lfSin - nHeight * lfCos)); +    } +    else +    { +        nNewWidth  = ROUND (fabs (nWidth * lfCos + nHeight * lfSin)); +        nNewHeight = ROUND (fabs (nWidth * lfSin + nHeight * lfCos)); +    } + +    // getting the destination's center position +     +    nhdx =  nNewWidth / 2; +    nhdy = nNewHeight / 2; + +    // getting the source's center position +     +    nhsx =  nWidth / 2; +    nhsy = nHeight / 2; + +    // now, we have to alloc a new image +     +    bool sixteenBit = m_orgImage.sixteenBit(); +     +    m_destImage = Digikam::DImg(nNewWidth, nNewHeight, sixteenBit, m_orgImage.hasAlpha()); +    m_destImage.fill( Digikam::DColor(m_backgroundColor.rgb(), sixteenBit) ); + +    uchar *pResBits            = m_destImage.bits(); +    unsigned short *pResBits16 = (unsigned short *)m_destImage.bits(); + +    Digikam::DImgImageFilters filters; +     +    // main loop +     +    for (h = 0; !m_cancel && (h < nNewHeight); h++) +    { +        nh = h - nhdy; + +        for (w = 0; !m_cancel && (w < nNewWidth); w++) +        { +            nw = w - nhdx; + +            i = setPosition (nNewWidth, w, h); +             +            lfx = (double)nw * lfCos - (double)nh * lfSin + nhsx; +            lfy = (double)nw * lfSin + (double)nh * lfCos + nhsy; + +            if (isInside (nWidth, nHeight, (int)lfx, (int)lfy)) +            { +                if (m_antiAlias) +                { +                    if (!sixteenBit) +                        filters.pixelAntiAliasing(pBits, nWidth, nHeight, lfx, lfy, +                                                  &pResBits[i+3], &pResBits[i+2], +                                                  &pResBits[i+1], &pResBits[i]); +                    else +                        filters.pixelAntiAliasing16(pBits16, nWidth, nHeight, lfx, lfy, +                                                    &pResBits16[i+3], &pResBits16[i+2], +                                                    &pResBits16[i+1], &pResBits16[i]); +                } +                else +                { +                    j = setPosition (nWidth, (int)lfx, (int)lfy); + +                    for (int p = 0 ; p < 4 ; p++) +                    { +                        if (!sixteenBit) +                            pResBits[i] = pBits[j]; +                        else +                            pResBits16[i] = pBits16[j]; +                         +                        i++; +                        j++; +                    } +                } +            } +        } + +        // Update the progress bar in dialog. +        progress = (int)(((double)h * 100.0) / nNewHeight); +        if (progress%5 == 0) +            postProgress( progress );         +    } + +    // Compute the rotated destination image size using original image dimensions. +    int W, H; +    double absAngle = fabs(m_angle); +     +    if (absAngle < 90.0) +    {       +        W = (int)(m_orgW * cos(absAngle * DEG2RAD) + m_orgH * sin(absAngle * DEG2RAD)); +        H = (int)(m_orgH * cos(absAngle * DEG2RAD) + m_orgW * sin(absAngle * DEG2RAD)); +    } +    else  +    {     +        H = (int)(m_orgW * cos((absAngle-90.0) * DEG2RAD) + m_orgH * sin((absAngle-90.0) * DEG2RAD)); +        W = (int)(m_orgH * cos((absAngle-90.0) * DEG2RAD) + m_orgW * sin((absAngle-90.0) * DEG2RAD)); +    } +     +    // Auto-cropping destination image without black holes around. +    TQRect autoCrop; +        +    switch(m_autoCrop) +    { +        case WidestArea: +        { +           // 'Widest Area' method (by Renchi Raju). +            +           autoCrop.setX( (int)(nHeight * sin(absAngle * DEG2RAD)) ); +           autoCrop.setY( (int)(nWidth  * sin(absAngle * DEG2RAD)) ); +           autoCrop.setWidth(  (int)(nNewWidth  - 2*nHeight * sin(absAngle * DEG2RAD)) ); +           autoCrop.setHeight( (int)(nNewHeight - 2*nWidth  * sin(absAngle * DEG2RAD)) ); + +           if (!autoCrop.isValid()) +           { +                m_destImage = Digikam::DImg(m_orgImage.width(), m_orgImage.height(),  +                               m_orgImage.sixteenBit(), m_orgImage.hasAlpha()); +                m_destImage.fill( Digikam::DColor(m_backgroundColor.rgb(), sixteenBit) ); +                m_newSize = TQSize(); +           } +           else +           { +                m_destImage = m_destImage.copy(autoCrop); +                m_newSize.setWidth(  (int)(W - 2*m_orgH * sin(absAngle * DEG2RAD)) ); +                m_newSize.setHeight( (int)(H - 2*m_orgW * sin(absAngle * DEG2RAD)) ); +           } +           break; +        } +        +        case LargestArea: +        { +           // 'Largest Area' method (by Gerhard Kulzer). +            +           float gamma = atan((float)nHeight / (float)nWidth); +            +           if (absAngle < 90.0) +           { +                autoCrop.setWidth( (int)((float)nHeight / cos(absAngle*DEG2RAD) / +                                   ( tan(gamma) + tan(absAngle*DEG2RAD) )) ); +                autoCrop.setHeight( (int)((float)autoCrop.width() * tan(gamma)) ); +           } +           else +           { +                autoCrop.setHeight( (int)((float)nHeight / cos((absAngle-90.0)*DEG2RAD) / +                                   ( tan(gamma) + tan((absAngle-90.0)*DEG2RAD) )) ); +                autoCrop.setWidth( (int)((float)autoCrop.height() * tan(gamma)) ); +           } +            +           autoCrop.moveCenter( TQPoint(nNewWidth/2, nNewHeight/2)); +            +           if (!autoCrop.isValid()) +           { +                m_destImage = Digikam::DImg(m_orgImage.width(), m_orgImage.height(),  +                              m_orgImage.sixteenBit(), m_orgImage.hasAlpha()); +                m_destImage.fill( Digikam::DColor(m_backgroundColor.rgb(), sixteenBit) ); +                m_newSize = TQSize(); +           } +           else +           {            +                m_destImage = m_destImage.copy(autoCrop); +                gamma = atan((float)m_orgH / (float)m_orgW); +                +                if (absAngle < 90.0) +                { +                    m_newSize.setWidth( (int)((float)m_orgH / cos(absAngle*DEG2RAD) /  +                                        ( tan(gamma) + tan(absAngle*DEG2RAD) )) ); +                    m_newSize.setHeight( (int)((float)m_newSize.width() * tan(gamma)) );                      +                } +                else +                { +                    m_newSize.setHeight( (int)((float)m_orgH / cos((absAngle-90.0)*DEG2RAD) / +                                        ( tan(gamma) + tan((absAngle-90.0)*DEG2RAD) )) ); +                    m_newSize.setWidth( (int)((float)m_newSize.height() * tan(gamma)) ); +                } +           } +           break; +        } +        default:   // No auto croping. +        { +           m_newSize.setWidth( W ); +           m_newSize.setHeight( H ); +           break; +        } +    } +} + +}  // NameSpace DigikamFreeRotationImagesPlugin diff --git a/src/imageplugins/freerotation/freerotation.h b/src/imageplugins/freerotation/freerotation.h new file mode 100644 index 00000000..7dc4cc8c --- /dev/null +++ b/src/imageplugins/freerotation/freerotation.h @@ -0,0 +1,94 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2005-07-18 + * Description : Free rotation threaded image filter. + *  + * Copyright (C) 2004-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 FREE_ROTATION_H +#define FREE_ROTATION_H + +// TQt includes. + +#include <tqsize.h> +#include <tqcolor.h> + +// Digikam includes. + +#include "dimgthreadedfilter.h" + +namespace DigikamFreeRotationImagesPlugin +{ + +class FreeRotation : public Digikam::DImgThreadedFilter +{ + +public: +     +    FreeRotation(Digikam::DImg *orgImage, TQObject *parent=0, double angle=0.0, +                 bool antialiasing=true, int autoCrop=NoAutoCrop, TQColor backgroundColor=TQt::black,  +                 int orgW=0, int orgH=0); +     +    ~FreeRotation(){}; +     +    TQSize getNewSize(void){ return m_newSize; }; + +public: +     +    enum AutoCropTypes  +    { +        NoAutoCrop=0, +        WidestArea, +        LargestArea +    }; +         +private:   + +    virtual void filterImage(void); +            +    inline int setPosition (int Width, int X, int Y) +    { +       return (Y *Width*4 + 4*X);  +    }; +     +    inline bool isInside (int Width, int Height, int X, int Y) +    { +       bool bIsWOk = ((X < 0) ? false : (X >= Width ) ? false : true); +       bool bIsHOk = ((Y < 0) ? false : (Y >= Height) ? false : true); +       return (bIsWOk && bIsHOk); +    }; + +private:   + +    bool   m_antiAlias; +     +    int    m_autoCrop; +    int    m_orgW; +    int    m_orgH; +     +    double m_angle; +     +    TQSize  m_newSize; +  +    TQColor m_backgroundColor; +};     + +}  // NameSpace DigikamFreeRotationImagesPlugin + +#endif /* FREE_ROTATION_H */ diff --git a/src/imageplugins/freerotation/freerotationtool.cpp b/src/imageplugins/freerotation/freerotationtool.cpp new file mode 100644 index 00000000..b25f2196 --- /dev/null +++ b/src/imageplugins/freerotation/freerotationtool.cpp @@ -0,0 +1,318 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + * + * 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 <tqcheckbox.h> +#include <tqimage.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqwhatsthis.h> + +// KDE includes. + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdeconfig.h> +#include <kcursor.h> +#include <kiconloader.h> +#include <tdelocale.h> +#include <kseparator.h> +#include <kstandarddirs.h> + +// LibKDcraw includes. + +#include <libkdcraw/rnuminput.h> +#include <libkdcraw/rcombobox.h> + +// Local includes. + +#include "daboutdata.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "editortoolsettings.h" +#include "freerotation.h" +#include "freerotationtool.h" +#include "freerotationtool.moc" + +using namespace KDcrawIface; +using namespace Digikam; + +namespace DigikamFreeRotationImagesPlugin +{ + +FreeRotationTool::FreeRotationTool(TQObject* parent) +                : EditorToolThreaded(parent) +{ +    setName("freerotation"); +    setToolName(i18n("Free Rotation")); +    setToolIcon(SmallIcon("freerotation")); + +    m_previewWidget = new ImageWidget("freerotation Tool", 0, +                                      i18n("<p>This is the free rotation operation preview. " +                                           "If you move the mouse cursor on this preview, " +                                           "a vertical and horizontal dashed line will be drawn " +                                           "to guide you in adjusting the free rotation correction. " +                                           "Release the left mouse button to freeze the dashed " +                                           "line's position."), +                                      false, ImageGuideWidget::HVGuideMode); + +    setToolView(m_previewWidget); + +    // ------------------------------------------------------------- + +    TQString temp; +    Digikam::ImageIface iface(0, 0); + +    m_gboxSettings = new EditorToolSettings(EditorToolSettings::Default| +                                            EditorToolSettings::Ok| +                                            EditorToolSettings::Cancel, +                                            EditorToolSettings::ColorGuide); +    TQGridLayout* grid = new TQGridLayout(m_gboxSettings->plainPage(), 9, 2); + +    TQLabel *label1  = new TQLabel(i18n("New width:"), m_gboxSettings->plainPage()); +    m_newWidthLabel = new TQLabel(temp.setNum( iface.originalWidth()) + i18n(" px"), m_gboxSettings->plainPage()); +    m_newWidthLabel->setAlignment( AlignBottom | AlignRight ); + +    TQLabel *label2   = new TQLabel(i18n("New height:"), m_gboxSettings->plainPage()); +    m_newHeightLabel = new TQLabel(temp.setNum( iface.originalHeight()) + i18n(" px"), m_gboxSettings->plainPage()); +    m_newHeightLabel->setAlignment( AlignBottom | AlignRight ); + +    KSeparator *line = new KSeparator(Horizontal, m_gboxSettings->plainPage()); + +    TQLabel *label3 = new TQLabel(i18n("Main angle:"), m_gboxSettings->plainPage()); +    m_angleInput   = new RIntNumInput(m_gboxSettings->plainPage()); +    m_angleInput->setRange(-180, 180, 1); +    m_angleInput->setDefaultValue(0); +    TQWhatsThis::add( m_angleInput, i18n("<p>An angle in degrees by which to rotate the image. " +                                        "A positive angle rotates the image clockwise; " +                                        "a negative angle rotates it counter-clockwise.")); + +    TQLabel *label4   = new TQLabel(i18n("Fine angle:"), m_gboxSettings->plainPage()); +    m_fineAngleInput = new RDoubleNumInput(m_gboxSettings->plainPage()); +    m_fineAngleInput->setRange(-5.0, 5.0, 0.01); +    m_fineAngleInput->setDefaultValue(0); +    TQWhatsThis::add( m_fineAngleInput, i18n("<p>This value in degrees will be added to main angle value " +                                            "to set fine target angle.")); + +    m_antialiasInput = new TQCheckBox(i18n("Anti-Aliasing"), m_gboxSettings->plainPage()); +    TQWhatsThis::add( m_antialiasInput, i18n("<p>Enable this option to apply the anti-aliasing filter " +                                            "to the rotated image. " +                                            "In order to smooth the target image, it will be blurred a little.")); + +    TQLabel *label5 = new TQLabel(i18n("Auto-crop:"), m_gboxSettings->plainPage()); +    m_autoCropCB   = new RComboBox(m_gboxSettings->plainPage()); +    m_autoCropCB->insertItem( i18n("None") ); +    m_autoCropCB->insertItem( i18n("Widest Area") ); +    m_autoCropCB->insertItem( i18n("Largest Area") ); +    m_autoCropCB->setDefaultItem(FreeRotation::NoAutoCrop); +    TQWhatsThis::add( m_autoCropCB, i18n("<p>Select the method to process image auto-cropping " +                                        "to remove black frames around a rotated image.")); + +    grid->addMultiCellWidget(label1,           0, 0, 0, 0); +    grid->addMultiCellWidget(m_newWidthLabel,  0, 0, 1, 2); +    grid->addMultiCellWidget(label2,           1, 1, 0, 0); +    grid->addMultiCellWidget(m_newHeightLabel, 1, 1, 1, 2); +    grid->addMultiCellWidget(line,             2, 2, 0, 2); +    grid->addMultiCellWidget(label3,           3, 3, 0, 2); +    grid->addMultiCellWidget(m_angleInput,     4, 4, 0, 2); +    grid->addMultiCellWidget(label4,           5, 5, 0, 2); +    grid->addMultiCellWidget(m_fineAngleInput, 6, 6, 0, 2); +    grid->addMultiCellWidget(m_antialiasInput, 7, 7, 0, 2); +    grid->addMultiCellWidget(label5,           8, 8, 0, 0); +    grid->addMultiCellWidget(m_autoCropCB,     8, 8, 1, 2); +    grid->setRowStretch(9, 10); +    grid->setMargin(m_gboxSettings->spacingHint()); +    grid->setSpacing(m_gboxSettings->spacingHint()); + +    setToolSettings(m_gboxSettings); +    init(); + +    // ------------------------------------------------------------- + +    connect(m_angleInput, TQ_SIGNAL(valueChanged(int)), +            this, TQ_SLOT(slotTimer())); + +    connect(m_fineAngleInput, TQ_SIGNAL(valueChanged(double)), +            this, TQ_SLOT(slotTimer())); + +    connect(m_antialiasInput, TQ_SIGNAL(toggled(bool)), +            this, TQ_SLOT(slotEffect())); + +    connect(m_autoCropCB, TQ_SIGNAL(activated(int)), +            this, TQ_SLOT(slotEffect())); + +    connect(m_gboxSettings, TQ_SIGNAL(signalColorGuideChanged()), +            this, TQ_SLOT(slotColorGuideChanged())); +} + +FreeRotationTool::~FreeRotationTool() +{ +} + +void FreeRotationTool::slotColorGuideChanged() +{ +    m_previewWidget->slotChangeGuideColor(m_gboxSettings->guideColor()); +    m_previewWidget->slotChangeGuideSize(m_gboxSettings->guideSize()); +} + +void FreeRotationTool::readSettings() +{ +    TDEConfig *config = kapp->config(); +    config->setGroup("freerotation Tool"); +    m_angleInput->setValue(config->readNumEntry("Main Angle", m_angleInput->defaultValue())); +    m_fineAngleInput->setValue(config->readDoubleNumEntry("Fine Angle", m_fineAngleInput->defaultValue())); +    m_autoCropCB->setCurrentItem(config->readNumEntry("Auto Crop Type", m_autoCropCB->defaultItem())); +    m_antialiasInput->setChecked(config->readBoolEntry("Anti Aliasing", true)); +    m_gboxSettings->setGuideColor(config->readColorEntry("Guide Color", &TQt::red)); +    m_gboxSettings->setGuideSize(config->readNumEntry("Guide Width", 1)); + +    slotColorGuideChanged(); +    slotEffect(); +} + +void FreeRotationTool::writeSettings() +{ +    TDEConfig *config = kapp->config(); +    config->setGroup("freerotation Tool"); +    config->writeEntry("Main Angle", m_angleInput->value()); +    config->writeEntry("Fine Angle", m_fineAngleInput->value()); +    config->writeEntry("Auto Crop Type", m_autoCropCB->currentItem()); +    config->writeEntry("Anti Aliasing", m_antialiasInput->isChecked()); +    config->writeEntry("Guide Color", m_gboxSettings->guideColor()); +    config->writeEntry("Guide Width", m_gboxSettings->guideSize()); +    m_previewWidget->writeSettings(); +    config->sync(); +} + +void FreeRotationTool::slotResetSettings() +{ +    m_angleInput->blockSignals(true); +    m_antialiasInput->blockSignals(true); +    m_autoCropCB->blockSignals(true); + +    m_angleInput->slotReset(); +    m_fineAngleInput->slotReset(); +    m_antialiasInput->setChecked(true); +    m_autoCropCB->slotReset(); + +    m_angleInput->blockSignals(false); +    m_antialiasInput->blockSignals(false); +    m_autoCropCB->blockSignals(false); +} + +void FreeRotationTool::prepareEffect() +{ +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    m_angleInput->setEnabled(false); +    m_fineAngleInput->setEnabled(false); +    m_antialiasInput->setEnabled(false); +    m_autoCropCB->setEnabled(false); + +    double angle      = m_angleInput->value() + m_fineAngleInput->value(); +    bool antialiasing = m_antialiasInput->isChecked(); +    int autocrop      = m_autoCropCB->currentItem(); +    TQColor background = toolView()->paletteBackgroundColor().rgb(); +    ImageIface* iface = m_previewWidget->imageIface(); +    int orgW          = iface->originalWidth(); +    int orgH          = iface->originalHeight(); + +    uchar *data = iface->getPreviewImage(); +    DImg image(iface->previewWidth(), iface->previewHeight(), iface->previewSixteenBit(), +               iface->previewHasAlpha(), data); +    delete [] data; + +    setFilter(dynamic_cast<DImgThreadedFilter*>(new FreeRotation(&image, this, angle, antialiasing, +                                                autocrop, background, orgW, orgH))); +} + +void FreeRotationTool::prepareFinal() +{ +    m_angleInput->setEnabled(false); +    m_fineAngleInput->setEnabled(false); +    m_antialiasInput->setEnabled(false); +    m_autoCropCB->setEnabled(false); + +    double angle      = m_angleInput->value() + m_fineAngleInput->value(); +    bool antialiasing = m_antialiasInput->isChecked(); +    int autocrop      = m_autoCropCB->currentItem(); +    TQColor background = TQt::black; + +    ImageIface iface(0, 0); +    int orgW = iface.originalWidth(); +    int orgH = iface.originalHeight(); + +    uchar *data = iface.getOriginalImage(); +    DImg orgImage(orgW, orgH, iface.originalSixteenBit(), iface.originalHasAlpha(), data); +    delete [] data; + +    setFilter(dynamic_cast<DImgThreadedFilter *>(new FreeRotation(&orgImage, this, angle, antialiasing, +                                                 autocrop, background, orgW, orgH))); +} + +void FreeRotationTool::putPreviewData() +{ +    ImageIface* iface = m_previewWidget->imageIface(); +    int w             = iface->previewWidth(); +    int h             = iface->previewHeight(); + +    DImg imTemp = filter()->getTargetImage().smoothScale(w, h, TQSize::ScaleMin); +    DImg imDest( w, h, filter()->getTargetImage().sixteenBit(), +                       filter()->getTargetImage().hasAlpha() ); + +    imDest.fill(DColor(toolView()->paletteBackgroundColor().rgb(), +                       filter()->getTargetImage().sixteenBit()) ); +    imDest.bitBltImage(&imTemp, (w-imTemp.width())/2, (h-imTemp.height())/2); + +    iface->putPreviewImage((imDest.smoothScale(iface->previewWidth(), +                                               iface->previewHeight())).bits()); + +    m_previewWidget->updatePreview(); +    TQSize newSize = dynamic_cast<FreeRotation*>(filter())->getNewSize(); +    TQString temp; +    m_newWidthLabel->setText(temp.setNum( newSize.width()) + i18n(" px") ); +    m_newHeightLabel->setText(temp.setNum( newSize.height()) + i18n(" px") ); +} + +void FreeRotationTool::putFinalData() +{ +    ImageIface iface(0, 0); +    DImg targetImage = filter()->getTargetImage(); +    iface.putOriginalImage(i18n("Free Rotation"), +                           targetImage.bits(), +                           targetImage.width(), targetImage.height()); +} + +void FreeRotationTool::renderingFinished() +{ +    m_angleInput->setEnabled(true); +    m_fineAngleInput->setEnabled(true); +    m_antialiasInput->setEnabled(true); +    m_autoCropCB->setEnabled(true); +    kapp->restoreOverrideCursor(); +} + +}  // NameSpace DigikamFreeRotationImagesPlugin diff --git a/src/imageplugins/freerotation/freerotationtool.h b/src/imageplugins/freerotation/freerotationtool.h new file mode 100644 index 00000000..fd17f4ff --- /dev/null +++ b/src/imageplugins/freerotation/freerotationtool.h @@ -0,0 +1,97 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + * + * 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 FREEROTATIONTOOL_H +#define FREEROTATIONTOOL_H + +// Local includes. + +#include "editortool.h" + +class TQFrame; +class TQLabel; +class TQCheckBox; + +namespace KDcrawIface +{ +class RIntNumInput; +class RDoubleNumInput; +class RComboBox; +} + +namespace Digikam +{ +class EditorToolSettings; +class ImageWidget; +} + +namespace DigikamFreeRotationImagesPlugin +{ + +class FreeRotationTool : public Digikam::EditorToolThreaded +{ +    TQ_OBJECT +   + +public: + +    FreeRotationTool(TQObject *parent); +    ~FreeRotationTool(); + +private slots: + +    void slotResetSettings(); +    void slotColorGuideChanged(); + +private: + +    void readSettings(); +    void writeSettings(); +    void prepareEffect(); +    void prepareFinal(); +    void putPreviewData(); +    void putFinalData(); +    void renderingFinished(); + +private: + +    TQLabel                       *m_newWidthLabel; +    TQLabel                       *m_newHeightLabel; + +    TQCheckBox                    *m_antialiasInput; + +    KDcrawIface::RComboBox       *m_autoCropCB; + +    KDcrawIface::RIntNumInput    *m_angleInput; + +    KDcrawIface::RDoubleNumInput *m_fineAngleInput; + +    Digikam::ImageWidget         *m_previewWidget; + +    Digikam::EditorToolSettings  *m_gboxSettings; +}; + +}  // NameSpace DigikamFreeRotationImagesPlugin + +#endif /* FREEROTATIONTOOL_H */ diff --git a/src/imageplugins/freerotation/imageeffect_freerotation.cpp b/src/imageplugins/freerotation/imageeffect_freerotation.cpp new file mode 100644 index 00000000..bce50f07 --- /dev/null +++ b/src/imageplugins/freerotation/imageeffect_freerotation.cpp @@ -0,0 +1,308 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + *  + * 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 <tqcheckbox.h> +#include <tqwhatsthis.h> +#include <tqlayout.h> +#include <tqimage.h> +#include <tqcombobox.h> + +// KDE includes. + +#include <tdelocale.h> +#include <tdeaboutdata.h> +#include <kiconloader.h> +#include <tdeapplication.h> +#include <kstandarddirs.h> +#include <knuminput.h> +#include <kcursor.h> +#include <kseparator.h> +#include <tdeconfig.h> + +// Local includes. + +#include "version.h" +#include "ddebug.h" +#include "dimg.h" +#include "imageiface.h" +#include "imagewidget.h" +#include "freerotation.h" +#include "imageeffect_freerotation.h" +#include "imageeffect_freerotation.moc" + +namespace DigikamFreeRotationImagesPlugin +{ + +ImageEffect_FreeRotation::ImageEffect_FreeRotation(TQWidget* parent) +                        : Digikam::ImageGuideDlg(parent, i18n("Free Rotation"), "freerotation", +                          false, true, true, Digikam::ImageGuideWidget::HVGuideMode) +{ +    // No need Abort button action. +    showButton(User1, false); + +    TQString whatsThis; + +    TDEAboutData* about = new TDEAboutData("digikam", +                                       I18N_NOOP("Free Rotation"), +                                       digikam_version, +                                       I18N_NOOP("A digiKam image plugin to process free image " +                                       "rotation."), +                                       TDEAboutData::License_GPL, +                                       "(c) 2004-2008, Gilles Caulier", +                                       0, +                                       "http://www.digikam.org"); + +    about->addAuthor("Gilles Caulier", I18N_NOOP("Author and maintainer"), +                     "caulier dot gilles at gmail dot com"); + +    about->addAuthor("Pieter Z. Voloshyn", I18N_NOOP("Free Rotation algorithm"), +                     "pieter dot voloshyn at gmail dot com"); + +    setAboutData(about); + +    TQWhatsThis::add( m_imagePreviewWidget, i18n("<p>This is the free image operation preview. " +                                           "If you move the mouse cursor on this preview, " +                                           "a vertical and horizontal dashed line will be drawn " +                                           "to guide you in adjusting the free rotation correction. " +                                           "Release the left mouse button to freeze the dashed " +                                           "line's position.")); + +    // ------------------------------------------------------------- + +    TQString temp; +    Digikam::ImageIface iface(0, 0); + +    TQWidget *gboxSettings     = new TQWidget(plainPage()); +    TQGridLayout* gridSettings = new TQGridLayout( gboxSettings, 9, 2, spacingHint()); + +    TQLabel *label1 = new TQLabel(i18n("New width:"), gboxSettings); +    m_newWidthLabel = new TQLabel(temp.setNum( iface.originalWidth()) + i18n(" px"), gboxSettings); +    m_newWidthLabel->setAlignment( AlignBottom | AlignRight ); + +    TQLabel *label2 = new TQLabel(i18n("New height:"), gboxSettings); +    m_newHeightLabel = new TQLabel(temp.setNum( iface.originalHeight()) + i18n(" px"), gboxSettings); +    m_newHeightLabel->setAlignment( AlignBottom | AlignRight ); + +    gridSettings->addMultiCellWidget(label1, 0, 0, 0, 0); +    gridSettings->addMultiCellWidget(m_newWidthLabel, 0, 0, 1, 2); +    gridSettings->addMultiCellWidget(label2, 1, 1, 0, 0); +    gridSettings->addMultiCellWidget(m_newHeightLabel, 1, 1, 1, 2); + +    KSeparator *line = new KSeparator(Horizontal, gboxSettings); +    gridSettings->addMultiCellWidget(line, 2, 2, 0, 2); + +    TQLabel *label3 = new TQLabel(i18n("Main angle:"), gboxSettings); +    m_angleInput = new KIntNumInput(gboxSettings); +    m_angleInput->setRange(-180, 180, 1, true); +    m_angleInput->setValue(0); +    TQWhatsThis::add( m_angleInput, i18n("<p>An angle in degrees by which to rotate the image. " +                                        "A positive angle rotates the image clockwise; " +                                        "a negative angle rotates it counter-clockwise.")); + +    gridSettings->addMultiCellWidget(label3, 3, 3, 0, 2); +    gridSettings->addMultiCellWidget(m_angleInput, 4, 4, 0, 2); + +    TQLabel *label4 = new TQLabel(i18n("Fine angle:"), gboxSettings); +    m_fineAngleInput = new KDoubleNumInput(gboxSettings); +    m_fineAngleInput->setRange(-5.0, 5.0, 0.01, true); +    m_fineAngleInput->setValue(0); +    TQWhatsThis::add( m_fineAngleInput, i18n("<p>This value in degrees will be added to main angle value " +                                            "to set fine target angle.")); + +    gridSettings->addMultiCellWidget(label4, 5, 5, 0, 2); +    gridSettings->addMultiCellWidget(m_fineAngleInput, 6, 6, 0, 2); + +    m_antialiasInput = new TQCheckBox(i18n("Anti-Aliasing"), gboxSettings); +    TQWhatsThis::add( m_antialiasInput, i18n("<p>Enable this option to apply the anti-aliasing filter " +                                            "to the rotated image. " +                                            "In order to smooth the target image, it will be blurred a little.")); +    gridSettings->addMultiCellWidget(m_antialiasInput, 7, 7, 0, 2); + +    TQLabel *label5 = new TQLabel(i18n("Auto-crop:"), gboxSettings); +    m_autoCropCB = new TQComboBox(false, gboxSettings); +    m_autoCropCB->insertItem( i18n("None") ); +    m_autoCropCB->insertItem( i18n("Widest Area") ); +    m_autoCropCB->insertItem( i18n("Largest Area") ); +    TQWhatsThis::add( m_autoCropCB, i18n("<p>Select the method to process image auto-cropping " +                                            "to remove black frames around a rotated image.")); +    gridSettings->addMultiCellWidget(label5, 8, 8, 0, 0); +    gridSettings->addMultiCellWidget(m_autoCropCB, 8, 8, 1, 2); + +    setUserAreaWidget(gboxSettings); + +    // ------------------------------------------------------------- + +    connect(m_angleInput, TQ_SIGNAL(valueChanged (int)), +            this, TQ_SLOT(slotTimer())); + +    connect(m_fineAngleInput, TQ_SIGNAL(valueChanged (double)), +            this, TQ_SLOT(slotTimer())); + +    connect(m_antialiasInput, TQ_SIGNAL(toggled (bool)), +            this, TQ_SLOT(slotEffect())); + +    connect(m_autoCropCB, TQ_SIGNAL(activated(int)), +            this, TQ_SLOT(slotEffect())); +} + +ImageEffect_FreeRotation::~ImageEffect_FreeRotation() +{ +} + +void ImageEffect_FreeRotation::readUserSettings(void) +{ +    TDEConfig *config = kapp->config(); +    config->setGroup("freerotation Tool Dialog"); +    m_angleInput->setValue(config->readNumEntry("Main Angle", 0)); +    m_fineAngleInput->setValue(config->readDoubleNumEntry("Fine Angle", 0.0)); +    m_autoCropCB->setCurrentItem(config->readNumEntry("Auto Crop Type", FreeRotation::NoAutoCrop)); +    m_antialiasInput->setChecked(config->readBoolEntry("Anti Aliasing", true)); +    slotEffect(); +} + +void ImageEffect_FreeRotation::writeUserSettings(void) +{ +    TDEConfig *config = kapp->config(); +    config->setGroup("freerotation Tool Dialog"); +    config->writeEntry("Main Angle", m_angleInput->value()); +    config->writeEntry("Fine Angle", m_fineAngleInput->value()); +    config->writeEntry( "Auto Crop Type", m_autoCropCB->currentItem() ); +    config->writeEntry( "Anti Aliasing", m_antialiasInput->isChecked() ); +    config->sync(); +} + +void ImageEffect_FreeRotation::resetValues() +{ +    m_angleInput->blockSignals(true); +    m_antialiasInput->blockSignals(true); +    m_autoCropCB->blockSignals(true); +    m_angleInput->setValue(0); +    m_fineAngleInput->setValue(0.0); +    m_antialiasInput->setChecked(true); +    m_autoCropCB->setCurrentItem(FreeRotation::NoAutoCrop); +    m_angleInput->blockSignals(false); +    m_antialiasInput->blockSignals(false); +    m_autoCropCB->blockSignals(false); +} + +void ImageEffect_FreeRotation::prepareEffect() +{ +    kapp->setOverrideCursor( KCursor::waitCursor() ); +    m_angleInput->setEnabled(false); +    m_fineAngleInput->setEnabled(false); +    m_antialiasInput->setEnabled(false); +    m_autoCropCB->setEnabled(false); + +    double angle      = m_angleInput->value() + m_fineAngleInput->value(); +    bool antialiasing = m_antialiasInput->isChecked(); +    int autocrop      = m_autoCropCB->currentItem(); +    TQColor background = paletteBackgroundColor().rgb(); + +    Digikam::ImageIface* iface = m_imagePreviewWidget->imageIface(); +    int orgW = iface->originalWidth(); +    int orgH = iface->originalHeight(); + +    uchar *data = iface->getPreviewImage(); +    Digikam::DImg image(iface->previewWidth(), iface->previewHeight(), iface->previewSixteenBit(), +                        iface->previewHasAlpha(), data); +    delete [] data;                         + +    m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>( +                       new FreeRotation(&image, this, angle, antialiasing, autocrop, +                                        background, orgW, orgH)); +} + +void ImageEffect_FreeRotation::prepareFinal() +{ +    m_angleInput->setEnabled(false); +    m_fineAngleInput->setEnabled(false); +    m_antialiasInput->setEnabled(false); +    m_autoCropCB->setEnabled(false); + +    double angle      = m_angleInput->value() + m_fineAngleInput->value(); +    bool antialiasing = m_antialiasInput->isChecked(); +    int autocrop      = m_autoCropCB->currentItem(); +    TQColor background = TQt::black; + +    Digikam::ImageIface iface(0, 0); +    int orgW = iface.originalWidth(); +    int orgH = iface.originalHeight(); +     +    uchar *data = iface.getOriginalImage(); +    Digikam::DImg orgImage(orgW, orgH, iface.originalSixteenBit(), +                           iface.originalHasAlpha(), data); +    delete [] data; +     +    m_threadedFilter = dynamic_cast<Digikam::DImgThreadedFilter *>( +                       new FreeRotation(&orgImage, this, angle, antialiasing, autocrop, +                                        background, orgW, orgH)); +} + +void ImageEffect_FreeRotation::putPreviewData(void) +{ +    Digikam::ImageIface* iface = m_imagePreviewWidget->imageIface(); +    int w = iface->previewWidth(); +    int h = iface->previewHeight(); + +    Digikam::DImg imTemp = m_threadedFilter->getTargetImage().smoothScale(w, h, TQSize::ScaleMin); +    Digikam::DImg imDest( w, h, m_threadedFilter->getTargetImage().sixteenBit(), +                                m_threadedFilter->getTargetImage().hasAlpha() ); +     +    imDest.fill( Digikam::DColor(paletteBackgroundColor().rgb(), +                                 m_threadedFilter->getTargetImage().sixteenBit()) ); +    imDest.bitBltImage(&imTemp, (w-imTemp.width())/2, (h-imTemp.height())/2); + +    iface->putPreviewImage((imDest.smoothScale(iface->previewWidth(), +                                               iface->previewHeight())).bits()); + +    m_imagePreviewWidget->updatePreview(); +    TQSize newSize = dynamic_cast<FreeRotation *>(m_threadedFilter)->getNewSize(); +    TQString temp; +    m_newWidthLabel->setText(temp.setNum( newSize.width()) + i18n(" px") ); +    m_newHeightLabel->setText(temp.setNum( newSize.height()) + i18n(" px") ); +} + +void ImageEffect_FreeRotation::putFinalData(void) +{ +    Digikam::ImageIface iface(0, 0); +    Digikam::DImg targetImage = m_threadedFilter->getTargetImage(); +    iface.putOriginalImage(i18n("Free Rotation"), +                           targetImage.bits(), +                           targetImage.width(), targetImage.height()); +} + +void ImageEffect_FreeRotation::renderingFinished() +{ +    m_angleInput->setEnabled(true); +    m_fineAngleInput->setEnabled(true); +    m_antialiasInput->setEnabled(true); +    m_autoCropCB->setEnabled(true); +    kapp->restoreOverrideCursor(); +} + +}  // NameSpace DigikamFreeRotationImagesPlugin + diff --git a/src/imageplugins/freerotation/imageeffect_freerotation.h b/src/imageplugins/freerotation/imageeffect_freerotation.h new file mode 100644 index 00000000..a90be09d --- /dev/null +++ b/src/imageplugins/freerotation/imageeffect_freerotation.h @@ -0,0 +1,83 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + *  + * 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_FREEROTATION_H +#define IMAGEEFFECT_FREEROTATION_H + +// Local includes. + +#include "imageguidedlg.h" + +class TQFrame; +class TQLabel; +class TQCheckBox; +class TQComboBox; + +class KIntNumInput; +class KDoubleNumInput; + +namespace DigikamFreeRotationImagesPlugin +{ + +class ImageEffect_FreeRotation : public Digikam::ImageGuideDlg +{ +    TQ_OBJECT +   +     +public: + +    ImageEffect_FreeRotation(TQWidget *parent); +    ~ImageEffect_FreeRotation(); + +private slots: +     +    void readUserSettings(void); + +protected: + +    void writeUserSettings();     +    void resetValues();    +    void prepareEffect(); +    void prepareFinal(); +    void putPreviewData(); +    void putFinalData(); +    void renderingFinished(); + +private: + +    TQLabel          *m_newWidthLabel; +    TQLabel          *m_newHeightLabel; + +    TQCheckBox       *m_antialiasInput; +     +    TQComboBox       *m_autoCropCB; +     +    KIntNumInput    *m_angleInput; + +    KDoubleNumInput *m_fineAngleInput; +}; + +}  // NameSpace DigikamFreeRotationImagesPlugin + +#endif /* IMAGEEFFECT_FREEROTATION_H */ diff --git a/src/imageplugins/freerotation/imageplugin_freerotation.cpp b/src/imageplugins/freerotation/imageplugin_freerotation.cpp new file mode 100644 index 00000000..0c04a2ca --- /dev/null +++ b/src/imageplugins/freerotation/imageplugin_freerotation.cpp @@ -0,0 +1,70 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + * + * 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 "freerotationtool.h" +#include "imageplugin_freerotation.h" +#include "imageplugin_freerotation.moc" + +using namespace DigikamFreeRotationImagesPlugin; + +K_EXPORT_COMPONENT_FACTORY(digikamimageplugin_freerotation, +                           KGenericFactory<ImagePlugin_FreeRotation>("digikamimageplugin_freerotation")); + +ImagePlugin_FreeRotation::ImagePlugin_FreeRotation(TQObject *parent, const char*, const TQStringList &) +                        : Digikam::ImagePlugin(parent, "ImagePlugin_FreeRotation") +{ +    m_freerotationAction = new TDEAction(i18n("Free Rotation..."), "freerotation", 0,  +                             this, TQ_SLOT(slotFreeRotation()), +                             actionCollection(), "imageplugin_freerotation"); + +    setXMLFile("digikamimageplugin_freerotation_ui.rc"); + +    DDebug() << "ImagePlugin_FreeRotation plugin loaded" << endl; +} + +ImagePlugin_FreeRotation::~ImagePlugin_FreeRotation() +{ +} + +void ImagePlugin_FreeRotation::setEnabledActions(bool enable) +{ +    m_freerotationAction->setEnabled(enable); +} + +void ImagePlugin_FreeRotation::slotFreeRotation() +{ +    FreeRotationTool *tool = new FreeRotationTool(this); +    loadTool(tool); +} diff --git a/src/imageplugins/freerotation/imageplugin_freerotation.h b/src/imageplugins/freerotation/imageplugin_freerotation.h new file mode 100644 index 00000000..2a0c2627 --- /dev/null +++ b/src/imageplugins/freerotation/imageplugin_freerotation.h @@ -0,0 +1,57 @@ +/* ============================================================ + * + * This file is a part of digiKam project + * http://www.digikam.org + * + * Date        : 2004-11-28 + * Description : a digiKam image editor plugin to process image + *               free rotation. + * + * 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_FREEROTATION_H +#define IMAGEPLUGIN_FREEROTATION_H + +// Digikam includes. + +#include "imageplugin.h" +#include "digikam_export.h" + +class TDEAction; + +class DIGIKAMIMAGEPLUGINS_EXPORT ImagePlugin_FreeRotation : public Digikam::ImagePlugin +{ +    TQ_OBJECT +   + +public: + +    ImagePlugin_FreeRotation(TQObject *parent, const char* name, +                             const TQStringList &args); +    ~ImagePlugin_FreeRotation(); + +    void setEnabledActions(bool enable); + +private slots: + +    void slotFreeRotation(); + +private: + +    TDEAction *m_freerotationAction; +}; + +#endif /* IMAGEPLUGIN_FREEROTATION_H */ | 
