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.
170 lines
5.0 KiB
170 lines
5.0 KiB
15 years ago
|
|
||
|
#include "kcolortest.h"
|
||
|
#include <kapplication.h>
|
||
|
#include <kimageeffect.h>
|
||
|
#include <stdio.h>
|
||
15 years ago
|
#include <tqdatetime.h>
|
||
15 years ago
|
|
||
|
bool fullscreen = false, oldway = false, intvsfade = false;
|
||
|
int max = 20; // how many steps
|
||
|
|
||
15 years ago
|
KColorWidget::KColorWidget(TQWidget *parent, const char *name)
|
||
|
: TQWidget(parent, name)
|
||
15 years ago
|
{
|
||
|
|
||
|
if (fullscreen || intvsfade) {
|
||
15 years ago
|
TQPixmap shot = TQPixmap::grabWindow(TQApplication::desktop()->winId());
|
||
15 years ago
|
original = shot.convertToImage();
|
||
|
}
|
||
|
else
|
||
15 years ago
|
original = TQImage("testimage.png");
|
||
15 years ago
|
resize(original.width(), original.height());
|
||
|
}
|
||
|
|
||
15 years ago
|
void KColorWidget::paintEvent(TQPaintEvent *)
|
||
15 years ago
|
{
|
||
|
if(!pixmap.isNull())
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
|
||
|
void KColorWidget::doIntensityLoop()
|
||
|
{
|
||
|
int count;
|
||
|
|
||
|
int start, stop;
|
||
15 years ago
|
TQTime t;
|
||
15 years ago
|
|
||
|
t.start();
|
||
|
|
||
|
image = original; image.detach();
|
||
|
|
||
|
if (fullscreen){
|
||
|
start = t.elapsed();
|
||
|
for(count=0; count < max; ++count){
|
||
|
if (!oldway)
|
||
|
KImageEffect::intensity(image, -1./max);
|
||
|
else {
|
||
|
uint *qptr=(uint *)image.bits();
|
||
|
QRgb qrgb;
|
||
|
int size=pixmap.width()*pixmap.height();
|
||
|
for (int i=0;i<size; i++, qptr++)
|
||
|
{
|
||
|
qrgb=*(QRgb *)qptr;
|
||
14 years ago
|
*qptr=tqRgb((int)(tqRed(qrgb)*1./max),
|
||
|
(int)(tqGreen(qrgb)*1./max),
|
||
|
(int)(tqBlue(qrgb)*1./max));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
stop = t.elapsed();
|
||
|
qDebug ("Total fullscreen %s dim time for %d steps : %f s",
|
||
|
oldway?"(antonio)":"(intensity)", count, (stop - start)*1e-3);
|
||
|
|
||
|
if (intvsfade) {
|
||
|
image = original; image.detach();
|
||
|
start = t.elapsed();
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::fade(image, 1./max, black);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
}
|
||
|
stop = t.elapsed();
|
||
|
qDebug ("Total fullscreen (fade) dim time for %d steps : %f s",
|
||
|
count, (stop - start)*1e-3);
|
||
|
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
image = original; image.detach();
|
||
|
qDebug("Intensity test");
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::intensity(image, 1./max);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::intensity(image, -1./max);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
|
||
|
image = original; image.detach();
|
||
|
qDebug("Red channel intensity test");
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, -1./max, KImageEffect::Red);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, 1./max, KImageEffect::Red);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
|
||
|
image = original; image.detach();
|
||
|
qDebug("Green channel intensity test");
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, -1./max, KImageEffect::Green);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, 1./max, KImageEffect::Green);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
|
||
|
image = original; image.detach();
|
||
|
qDebug("Blue channel intensity test");
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, -1./max, KImageEffect::Blue);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
for(count=0; count < max; ++count){
|
||
|
KImageEffect::channelIntensity(image, 1./max, KImageEffect::Blue);
|
||
|
pixmap.convertFromImage(image);
|
||
|
bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(),
|
||
|
Qt::CopyROP, true);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
if (argc > 1) {
|
||
|
if (!strcmp(argv[1], "fullscreen"))
|
||
|
{
|
||
|
fullscreen = true;
|
||
|
if (!strcmp(argv[2], "old_way"))
|
||
|
oldway = true;
|
||
|
}
|
||
|
else if (!strcmp(argv[1], "int_vs_fade")) {
|
||
|
intvsfade = fullscreen = true;
|
||
|
oldway = false;
|
||
|
}
|
||
|
else
|
||
|
printf("Usage: %s [int_vs_fade | fullscreen [old_way]]\n ", argv[0]);
|
||
|
}
|
||
|
KApplication *app = new KApplication(argc, argv, "KColorTest");
|
||
|
KColorWidget w;
|
||
|
app->setMainWidget(&w);
|
||
|
w.show();
|
||
|
w.doIntensityLoop();
|
||
|
return(app->exec());
|
||
|
}
|