summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-07-28 09:55:20 +0200
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-07-28 10:36:08 +0200
commitac92e906114ed7216cfd99e0deecfb7be0fd91ec (patch)
treefb7d2dd912642eda1a6bba4be2c76f46da832339 /src/gui/painting
parent8cfdb13015a58905539c25334e05492f9afe103b (diff)
Fixed drawImage() so that it doesn't sample outside the source image.
In qt_scale_image_16bit() and qt_scale_image_32bit(), when a sample point was located on the border between two pixels in the source image, the sample point was rounded up instead of down. If a sample point was exactly on the bottom or right edge of the source image, the function would therefore sample a pixel outside the image. Because of how the target rectangle is rounded, a sample point will never be exactly on the top or left edge of the source image, so we will not get a similar problem there. I extended the lance test pixmap_scaling.qps. Task-number: 258533 Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qblendfunctions.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index baea1400fa..82abec304d 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -192,8 +192,8 @@ void qt_scale_image_16bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix);
- const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy);
+ const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;
@@ -667,8 +667,8 @@ template <typename T> void qt_scale_image_32bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix);
- const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy);
+ const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;