diff options
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 21 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 78515ac..37f7b6d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1771,10 +1771,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) static inline QRect toNormalizedFillRect(const QRectF &rect) { - int x1 = int(rect.x() + aliasedCoordinateDelta); - int y1 = int(rect.y() + aliasedCoordinateDelta); - int x2 = int(rect.right() + aliasedCoordinateDelta); - int y2 = int(rect.bottom() + aliasedCoordinateDelta); + int x1 = qRound(rect.x() + aliasedCoordinateDelta); + int y1 = qRound(rect.y() + aliasedCoordinateDelta); + int x2 = qRound(rect.right() + aliasedCoordinateDelta); + int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); if (x2 < x1) qSwap(x1, x2); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 7e42da8..5e5bd39 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -202,6 +202,7 @@ private slots: void drawImage_task217400_data(); void drawImage_task217400(); + void drawImage_1x1(); void drawRect_task215378(); void drawRect_task247505(); @@ -4237,5 +4238,25 @@ void tst_QPainter::emptyClip() p.fillPath(path, Qt::green); } +void tst_QPainter::drawImage_1x1() +{ + QImage source(1, 1, QImage::Format_ARGB32_Premultiplied); + source.fill(0xffffffff); + + QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); + img.fill(0xff000000); + QPainter p(&img); + p.drawImage(QRectF(0.9, 0.9, 32, 32), source); + p.end(); + + QImage expected = img; + expected.fill(0xff000000); + p.begin(&expected); + p.fillRect(1, 1, 31, 31, Qt::white); + p.end(); + + QCOMPARE(img, expected); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |