summaryrefslogtreecommitdiffstats
path: root/kdeui/tests/kdesattest.cpp
blob: 28f7d4cf29ce46039ddbce98a76c187eac22496a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "kdesattest.h"
#include <kapplication.h>
#include <kimageeffect.h>
#include <tqpainter.h>
#include <tqdatetime.h>
#include <tqstring.h>

int cols = 3, rows = 3; // how many

KDesatWidget::KDesatWidget(TQWidget *parent, const char *name)
  :TQWidget(parent, name)
{

    image = TQImage("testimage.png");
    slide = new KDoubleNumInput(700, this, "desat");
    slide->setRange(0, 1, 0.001);
    slide->setLabel("Desaturate: ", AlignVCenter | AlignLeft);
    connect(slide,TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(change(double)));

    resize(image.width()*2, image.height() + slide->height());
    slide->setGeometry(0, image.height(), image.width()*2, slide->height());
}

void KDesatWidget::change(double) {
    desat_value = slide->value();
    repaint(false);
}

void KDesatWidget::paintEvent(TQPaintEvent */*ev*/)
{
    TQTime time;
    int it, ft;
    TQString say;

    TQPainter p(this);
    p.setPen(Qt::black);

    // original image
    time.start();
    it = time.elapsed();
    image = TQImage("testimage.png");
    p.drawImage(0, 0, image);
    ft = time.elapsed();
    say.setNum( ft - it); say += " ms, Vertical";
    p.drawText(5 , 15, say);

    // desaturated image
    it = time.elapsed();
    image = KImageEffect::desaturate(image, desat_value);
    p.drawImage(image.width(), 0, image);
    ft = time.elapsed();
    say.setNum( ft - it); say += " ms, Horizontal";
    p.drawText(15+image.width() , 15, say);
}

int main(int argc, char **argv)
{
    KApplication *app = new KApplication(argc, argv, "KDesatTest");
    KDesatWidget w;
    app->setMainWidget(&w);
    w.show();
    return(app->exec());
}

#include "kdesattest.moc"