~ubuntu-branches/ubuntu/raring/digikam/raring

« back to all changes in this revision

Viewing changes to core/imageplugins/decorate/inserttextwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Date        : 2005-02-14
7
7
 * Description : a widget to insert a text over an image.
8
8
 *
9
 
 * Copyright (C) 2005-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
 
 * Copyright (C) 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
9
 * Copyright (C) 2005-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2006-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11
11
 *
12
12
 * This program is free software; you can redistribute it
13
13
 * and/or modify it under the terms of the GNU General
52
52
namespace DigikamDecorateImagePlugin
53
53
{
54
54
 
55
 
class InsertTextWidget::InsertTextWidgetPriv
 
55
class InsertTextWidget::Private
56
56
{
57
57
public:
58
58
 
59
 
    InsertTextWidgetPriv() :
60
 
        data(0),
 
59
    Private() :
61
60
        currentMoving(false),
62
61
        textBorder(false),
63
62
        textTransparent(false),
73
72
    {
74
73
    }
75
74
 
76
 
    uchar*      data;
77
 
 
78
75
    bool        currentMoving;
79
76
    bool        textBorder;
80
77
    bool        textTransparent;
104
101
    ImageIface* iface;
105
102
};
106
103
 
107
 
InsertTextWidget::InsertTextWidget(int w, int h, QWidget* parent)
 
104
InsertTextWidget::InsertTextWidget(int w, int h, QWidget* const parent)
108
105
    : QWidget(parent),
109
 
      d(new InsertTextWidgetPriv)
 
106
      d(new Private)
110
107
{
111
108
    d->currentMoving   = false;
112
109
    d->bgColor         = palette().color(QPalette::Background);
113
110
    d->backgroundColor = QColor(0xCC, 0xCC, 0xCC);
114
111
    d->transparency    = 210;
115
112
 
116
 
    d->iface  = new ImageIface(w, h);
117
 
    d->data   = d->iface->getPreviewImage();
118
 
    d->w      = d->iface->previewWidth();
119
 
    d->h      = d->iface->previewHeight();
 
113
    d->iface  = new ImageIface(QSize(w, h));
 
114
    d->w      = d->iface->previewSize().width();
 
115
    d->h      = d->iface->previewSize().height();
120
116
    d->pixmap = new QPixmap(w, h);
121
117
    d->pixmap->fill(d->bgColor);
122
118
 
130
126
 
131
127
InsertTextWidget::~InsertTextWidget()
132
128
{
133
 
    delete [] d->data;
134
129
    delete d->iface;
135
130
    delete d->pixmap;
136
131
    delete d;
234
229
 
235
230
DImg InsertTextWidget::makeInsertText()
236
231
{
237
 
    int orgW     = d->iface->originalWidth();
238
 
    int orgH     = d->iface->originalHeight();
 
232
    int orgW     = d->iface->originalSize().width();
 
233
    int orgH     = d->iface->originalSize().height();
239
234
    float ratioW = (float)orgW/(float)d->w;
240
235
    float ratioH = (float)orgH/(float)d->h;
241
236
 
254
249
    }
255
250
 
256
251
    // Get original image
257
 
    DImg image      = d->iface->getOriginalImg()->copy();
 
252
    DImg image      = d->iface->original()->copy();
258
253
    int borderWidth = qMax(1, (int)lroundf(ratioW));
259
254
 
260
255
    // compose and draw result on image
269
264
 
270
265
void InsertTextWidget::makePixmap()
271
266
{
272
 
    int orgW = d->iface->originalWidth();
273
 
    int orgH = d->iface->originalHeight();
 
267
    int orgW = d->iface->originalSize().width();
 
268
    int orgH = d->iface->originalSize().height();
274
269
    float ratioW = (float)d->w / (float)orgW;
275
270
    float ratioH = (float)d->h / (float)orgH;
276
271
 
289
284
    }
290
285
 
291
286
    // get preview image data
292
 
    QScopedArrayPointer<uchar> data(d->iface->getPreviewImage());
293
 
    DImg image(d->iface->previewWidth(), d->iface->previewHeight(), d->iface->previewSixteenBit(),
294
 
               d->iface->previewHasAlpha(), data.data());
295
 
    image.setIccProfile( d->iface->getOriginalImg()->getIccProfile() );
 
287
    DImg image = d->iface->preview();
 
288
    image.setIccProfile( d->iface->original()->getIccProfile() );
296
289
 
297
290
    // paint pixmap for drawing this widget
298
291
    // First, fill with background color
330
323
   if destPainter is not null, draw directly using the painter.
331
324
   Returns modified area of image.
332
325
*/
333
 
QRect InsertTextWidget::composeImage(DImg* image, QPainter* destPainter,
 
326
QRect InsertTextWidget::composeImage(DImg* const image, QPainter* const destPainter,
334
327
                                     int x, int y,
335
328
                                     QFont font, float pointSize, int textRotation, QColor textColor,
336
329
                                     int alignMode, const QString& textString,
642
635
    blockSignals(true);
643
636
    delete d->pixmap;
644
637
 
645
 
    int w = e->size().width();
646
 
    int h = e->size().height();
 
638
    int w     = e->size().width();
 
639
    int h     = e->size().height();
647
640
 
648
641
    int textX = d->textRect.x() - d->rect.x();
649
642
    int textY = d->textRect.y() - d->rect.y();
650
643
    int old_w = d->w;
651
644
    int old_h = d->h;
652
 
    d->data    = d->iface->setPreviewImageSize(w, h);
653
 
    d->w       = d->iface->previewWidth();
654
 
    d->h       = d->iface->previewHeight();
 
645
    d->iface->setPreviewSize(QSize(w, h));
 
646
    d->w      = d->iface->previewSize().width();
 
647
    d->h      = d->iface->previewSize().height();
655
648
 
656
649
    d->pixmap = new QPixmap(w, h);
657
 
    d->rect = QRect(w/2-d->w/2, h/2-d->h/2, d->w, d->h);
 
650
    d->rect   = QRect(w/2-d->w/2, h/2-d->h/2, d->w, d->h);
658
651
 
659
652
    if (d->textRect.isValid())
660
653
    {
661
654
        int textWidth  = d->textRect.width();
662
655
        int textHeight = d->textRect.height();
663
656
 
664
 
        textX = lroundf( textX * (float)d->w / (float)old_w );
665
 
        textY = lroundf( textY * (float)d->h / (float)old_h );
666
 
        textWidth  = lroundf(textWidth  * (float)d->w / (float)old_w );
667
 
        textHeight = lroundf(textHeight * (float)d->h / (float)old_h );
 
657
        textX      = lroundf(textX      * (float)d->w / (float)old_w);
 
658
        textY      = lroundf(textY      * (float)d->h / (float)old_h);
 
659
        textWidth  = lroundf(textWidth  * (float)d->w / (float)old_w);
 
660
        textHeight = lroundf(textHeight * (float)d->h / (float)old_h);
668
661
 
669
662
        d->textRect.setX(textX + d->rect.x());
670
663
        d->textRect.setY(textY + d->rect.y());