summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-29 11:56:16 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-09 14:04:13 +0100
commit04413b9dd8f3983fd5471354a48ad1257ca4f290 (patch)
treed5483c6d5f07251c18306e7f29ccbe5430b0761c /tests/auto/gui/image
parentccc205bf38ffbe60180a069939a4aff01e7734e5 (diff)
Allow painting above INT16_MAX on 64-bit architectures
The logic in qgrayraster was ready for it except for an intermediate format. qrasterizer.cpp and qcosmeticstroker.cpp uses a dot-16 fixed point format, and had to be changed to handle higher coordinates on 64-bit architectures. Fixes: QTBUG-84428 Change-Id: I85ab7a04e38bd0dbcefa9f16c16ccc84785a33cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/gui/image')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 7ef700c01d..141cc26aff 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -240,6 +240,9 @@ private slots:
void wideImage();
+ void largeFillScale();
+ void largeRasterScale();
+
#if defined(Q_OS_WIN)
void toWinHBITMAP_data();
void toWinHBITMAP();
@@ -3837,6 +3840,67 @@ void tst_QImage::wideImage()
// Qt6: Test that it actually works on 64bit architectures.
}
+void tst_QImage::largeFillScale()
+{
+#if Q_PROCESSOR_WORDSIZE < 8
+ QSKIP("Test fails on 32-bit builds");
+#endif
+ // Test from QTBUG-84428
+ QImage input(QSize(std::numeric_limits<qint16>::max() + 10, 1), QImage::Format_ARGB32_Premultiplied);
+ input.fill(Qt::white);
+
+ const int scaleFactor = 2;
+ QImage scaled = input.scaled(input.width(), input.height() * scaleFactor);
+
+ for (int x = 0, w = input.width(); x < w; ++x) {
+ const auto inputPixel = input.pixel(x, 0);
+ auto scaledPixel = scaled.pixel(x, 0);
+ QCOMPARE(scaledPixel, inputPixel);
+ scaledPixel = scaled.pixel(x, 1);
+ QCOMPARE(scaledPixel, inputPixel);
+ }
+}
+
+void tst_QImage::largeRasterScale()
+{
+#if Q_PROCESSOR_WORDSIZE < 8
+ QSKIP("Test fails on 32-bit builds");
+#endif
+ // Now test that qgrayraster still works at these ranges
+ QImage image(QSize(40000, 200), QImage::Format_RGB32);
+ image.fill(Qt::white);
+
+ QPainter painter(&image);
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ painter.setBrush(Qt::black);
+ painter.drawEllipse(QPoint(33000, 100), 6990, 99);
+ painter.end();
+ QCOMPARE(image.pixelColor(27000, 10), Qt::white);
+ QCOMPARE(image.pixelColor(33000, 10), Qt::black);
+ QCOMPARE(image.pixelColor(39000, 10), Qt::white);
+ QCOMPARE(image.pixelColor(27000, 100), Qt::black);
+ QCOMPARE(image.pixelColor(33000, 100), Qt::black);
+ QCOMPARE(image.pixelColor(39000, 100), Qt::black);
+ QCOMPARE(image.pixelColor(27000, 190), Qt::white);
+ QCOMPARE(image.pixelColor(33000, 190), Qt::black);
+ QCOMPARE(image.pixelColor(39000, 190), Qt::white);
+
+ // Now check grayscale antialiasing takes place in the higher coords
+ bool grayObserved = false;
+ for (int x = 33000; x < 39000; ++x) {
+ QRgb pixel = image.pixel(x, 20);
+ if (pixel == 0xff000000)
+ continue; // still black
+ if (pixel == 0xffffffff) {
+ QVERIFY(grayObserved);
+ break;
+ }
+ grayObserved = true;
+ }
+
+// image.save("largeRasterScale.png", "PNG");
+}
+
#if defined(Q_OS_WIN)
static inline QColor COLORREFToQColor(COLORREF cr)