summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmapfilter
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@nokia.com>2009-09-14 10:24:33 (GMT)
committerAriya Hidayat <ariya.hidayat@nokia.com>2009-09-14 13:10:13 (GMT)
commit97594601ca84ae11f30bb35e6cbc7e3f70e0624d (patch)
tree88a755b717059517cd8d5e6d1fa7499ed3c221de /tests/auto/qpixmapfilter
parentf272d891a1fb622ced7a92d426099996f7890945 (diff)
downloadQt-97594601ca84ae11f30bb35e6cbc7e3f70e0624d.zip
Qt-97594601ca84ae11f30bb35e6cbc7e3f70e0624d.tar.gz
Qt-97594601ca84ae11f30bb35e6cbc7e3f70e0624d.tar.bz2
Add strength factor to the colorize filter.
To allow fading between the original and the colorized version of the pixmaps, a new strength factor is introduced, 0.0 means the filter has no effect at all, 1.0 means full colorization. Still missing is the non-raster implementation. Autotest: included Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'tests/auto/qpixmapfilter')
-rw-r--r--tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
index 83bd537..5a9bad7 100644
--- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -63,8 +63,10 @@ public slots:
private slots:
void colorizeSetColor();
+ void colorizeSetStrength();
void colorizeProcess();
void colorizeDraw();
+ void colorizeDrawStrength();
void colorizeDrawSubRect();
void colorizeProcessSubRect();
void convolutionBoundingRectFor();
@@ -127,6 +129,16 @@ void tst_QPixmapFilter::colorizeSetColor()
QCOMPARE(filter.color(), QColor(50, 100, 200));
}
+void tst_QPixmapFilter::colorizeSetStrength()
+{
+ QPixmapColorizeFilter filter;
+ QCOMPARE(filter.strength(), qreal(1));
+ filter.setStrength(0.5);
+ QCOMPARE(filter.strength(), qreal(0.5));
+ filter.setStrength(0.0);
+ QCOMPARE(filter.strength(), qreal(0.0));
+}
+
void tst_QPixmapFilter::colorizeProcess()
{
QPixmapColorizeFilter filter;
@@ -180,6 +192,35 @@ void tst_QPixmapFilter::colorizeDraw()
}
}
+void tst_QPixmapFilter::colorizeDrawStrength()
+{
+ QPixmapColorizeFilter filter;
+ filter.setColor(Qt::blue);
+ filter.setStrength(0.3);
+
+ QImage source(256, 128, QImage::Format_ARGB32);
+ source.fill(qRgb(255, 0, 0));
+ QPixmap pixmap = QPixmap::fromImage(source);
+
+ QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied);
+ QPainter painter(&result);
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ filter.draw(&painter, QPointF(0, 0), pixmap);
+ painter.end();
+
+ QImage resultImg = result;
+ for(int y = 0; y < resultImg.height(); y++)
+ {
+ for(int x = 0; x < resultImg.width(); x++)
+ {
+ QRgb pixel = resultImg.pixel(x,y);
+ QCOMPARE(qRed(pixel), 206);
+ QCOMPARE(qGreen(pixel), 26);
+ QCOMPARE(qBlue(pixel), 75);
+ }
+ }
+}
+
void tst_QPixmapFilter::colorizeDrawSubRect()
{
QPixmapColorizeFilter filter;