You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
15 years ago
|
#include "kdesattest.h"
|
||
|
#include <kapplication.h>
|
||
|
#include <kimageeffect.h>
|
||
15 years ago
|
#include <tqpainter.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqstring.h>
|
||
15 years ago
|
|
||
|
int cols = 3, rows = 3; // how many
|
||
|
|
||
15 years ago
|
KDesatWidget::KDesatWidget(TQWidget *parent, const char *name)
|
||
|
:TQWidget(parent, name)
|
||
15 years ago
|
{
|
||
|
|
||
15 years ago
|
image = TQImage("testimage.png");
|
||
15 years ago
|
slide = new KDoubleNumInput(700, this, "desat");
|
||
|
slide->setRange(0, 1, 0.001);
|
||
|
slide->setLabel("Desaturate: ", AlignVCenter | AlignLeft);
|
||
15 years ago
|
connect(slide,TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(change(double)));
|
||
15 years ago
|
|
||
|
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();
|
||
14 years ago
|
tqrepaint(false);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void KDesatWidget::paintEvent(TQPaintEvent */*ev*/)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQTime time;
|
||
15 years ago
|
int it, ft;
|
||
15 years ago
|
TQString say;
|
||
15 years ago
|
|
||
15 years ago
|
TQPainter p(this);
|
||
15 years ago
|
p.setPen(Qt::black);
|
||
|
|
||
|
// original image
|
||
|
time.start();
|
||
|
it = time.elapsed();
|
||
15 years ago
|
image = TQImage("testimage.png");
|
||
15 years ago
|
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"
|