summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimage
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-22 09:04:29 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-22 09:25:54 +0200
commitaed5a7168354c6ae47687d20b4bd3f0adcc14f8e (patch)
treed2060479a7c12fdba8c1955e5d363754feffabb8 /tests/auto/gui/image/qimage
parentd3d10cf23d61f4a011f1a7e9abdee1a92717e80f (diff)
parent628fa13ea4d6ff0e2e2ee76c9adfc78676de3c59 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/gui/painting/qdrawhelper.cpp src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/plugins/platforms/xcb/qxcbwindow.h src/testlib/qtestblacklist.cpp src/tools/qdoc/node.cpp src/tools/qdoc/node.h tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
Diffstat (limited to 'tests/auto/gui/image/qimage')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp103
1 files changed, 57 insertions, 46 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 660809fb16..525d5b33a0 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -108,6 +108,7 @@ private slots:
void cacheKey();
void smoothScale();
+ void smoothScale2_data();
void smoothScale2();
void smoothScale3();
@@ -1539,58 +1540,68 @@ void tst_QImage::smoothScale()
}
// test area sampling
-void tst_QImage::smoothScale2()
+void tst_QImage::smoothScale2_data()
{
- int sizes[] = { 2, 4, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 };
- QImage::Format formats[] = { QImage::Format_ARGB32, QImage::Format_RGB32, QImage::Format_Invalid };
- for (int i = 0; sizes[i] != 0; ++i) {
- for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) {
- int size = sizes[i];
-
- QRgb expected = formats[j] == QImage::Format_ARGB32 ? qRgba(63, 127, 255, 255) : qRgb(63, 127, 255);
-
- QImage img(size, size, formats[j]);
- img.fill(expected);
+ QTest::addColumn<int>("format");
+ QTest::addColumn<int>("size");
+
+ int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 };
+ QImage::Format formats[] = { QImage::Format_RGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Invalid };
+ for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) {
+ QString formatstr = formats[j] == QImage::Format_RGB32 ? QStringLiteral("rgb32") : QStringLiteral("argb32pm");
+ for (int i = 0; sizes[i] != 0; ++i) {
+ QTest::newRow(QString("%1 %2x%2").arg(formatstr).arg(sizes[i]).toUtf8()) << (int)formats[j] << sizes[i];
+ }
+ }
+}
- // scale x down, y down
- QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- QRgb pixel = scaled.pixel(0, 0);
+void tst_QImage::smoothScale2()
+{
+ QFETCH(int, format);
+ QFETCH(int, size);
+
+ QRgb expected = format == QImage::Format_RGB32 ? qRgb(63, 127, 255) : qRgba(31, 63, 127, 127);
+
+ QImage img(size, size, (QImage::Format)format);
+ img.fill(expected);
+
+ // scale x down, y down
+ QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QRgb pixel = scaled.pixel(0, 0);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+
+ // scale x down, y up
+ scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ pixel = scaled.pixel(0, y);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+
+ // scale x up, y down
+ scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, 0);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+
+ // scale x up, y up
+ scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, y);
QCOMPARE(qAlpha(pixel), qAlpha(expected));
QCOMPARE(qRed(pixel), qRed(expected));
QCOMPARE(qGreen(pixel), qGreen(expected));
QCOMPARE(qBlue(pixel), qBlue(expected));
-
- // scale x down, y up
- scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int y = 0; y < scaled.height(); ++y) {
- pixel = scaled.pixel(0, y);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
-
- // scale x up, y down
- scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int x = 0; x < scaled.width(); ++x) {
- pixel = scaled.pixel(x, 0);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
-
- // scale x up, y up
- scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- for (int y = 0; y < scaled.height(); ++y) {
- for (int x = 0; x < scaled.width(); ++x) {
- pixel = scaled.pixel(x, y);
- QCOMPARE(qAlpha(pixel), qAlpha(expected));
- QCOMPARE(qRed(pixel), qRed(expected));
- QCOMPARE(qGreen(pixel), qGreen(expected));
- QCOMPARE(qBlue(pixel), qBlue(expected));
- }
- }
}
}
}