summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp26
2 files changed, 28 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 58ffb02..1a1c204 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1053,7 +1053,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = x + iw - cx2;
iw -= d;
}
- if (iw < 0)
+ if (iw <= 0)
return;
// adapt the y paremeters...
@@ -1070,7 +1070,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = y + ih - cy2;
ih -= d;
}
- if (ih < 0)
+ if (ih <= 0)
return;
// call the blend function...
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 87f9c13..8d6c9d2 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -215,6 +215,7 @@ private slots:
void imageCoordinateLimit();
void imageBlending_data();
void imageBlending();
+ void imageBlending_clipped();
void paintOnNullPixmap();
void checkCompositionMode();
@@ -3792,6 +3793,31 @@ void tst_QPainter::imageBlending()
}
}
+void tst_QPainter::imageBlending_clipped()
+{
+ QImage src(20, 20, QImage::Format_RGB16);
+ QPainter p(&src);
+ p.fillRect(src.rect(), Qt::red);
+ p.end();
+
+ QImage dst(40, 20, QImage::Format_RGB16);
+ p.begin(&dst);
+ p.fillRect(dst.rect(), Qt::white);
+ p.end();
+
+ QImage expected = dst;
+
+ p.begin(&dst);
+ p.setClipRect(QRect(23, 0, 20, 20));
+
+ // should be completely clipped
+ p.drawImage(QRectF(3, 0, 20, 20), src);
+ p.end();
+
+ // dst should be left unchanged
+ QCOMPARE(dst, expected);
+}
+
void tst_QPainter::paintOnNullPixmap()
{
QPixmap pix(16, 16);