summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
commit1c8451bdbbd6ca909dfc5b96a24be909810522fc (patch)
tree9cc69a4794e23f7224d75fc2323fc70e294a9454 /src/gui/image/qimage.cpp
parent7ebec0fa848de299d4cdee06ccc611ee46494fbf (diff)
parent0635b1a69dd666f5eed4b096895bd80b1a9420ff (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/tools/qdoc/tree.cpp tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: Iaa78f601a63191fa643aabf853520f913f2f0fdc
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r--src/gui/image/qimage.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index cac3d268c5..8373a5556b 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2924,14 +2924,22 @@ template<class T> inline void do_mirror_data(QImageData *dst, QImageData *src,
if (dst == src) {
// When mirroring in-place, stop in the middle for one of the directions, since we
// are swapping the bytes instead of merely copying.
- const int srcXEnd = dstX0 ? w / 2 : w;
- const int srcYEnd = !dstX0 && dstY0 ? h / 2 : h;
+ const int srcXEnd = (dstX0 && !dstY0) ? w / 2 : w;
+ const int srcYEnd = dstY0 ? h / 2 : h;
for (int srcY = 0, dstY = dstY0; srcY < srcYEnd; ++srcY, dstY += dstYIncr) {
T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);
T *dstPtr = (T *) (dst->data + dstY * dst->bytes_per_line);
for (int srcX = 0, dstX = dstX0; srcX < srcXEnd; ++srcX, dstX += dstXIncr)
std::swap(srcPtr[srcX], dstPtr[dstX]);
}
+ // If mirroring both ways, the middle line needs to be mirrored horizontally only.
+ if (dstX0 && dstY0 && (h & 1)) {
+ int srcY = h / 2;
+ int srcXEnd2 = w / 2;
+ T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);
+ for (int srcX = 0, dstX = dstX0; srcX < srcXEnd2; ++srcX, dstX += dstXIncr)
+ std::swap(srcPtr[srcX], srcPtr[dstX]);
+ }
} else {
for (int srcY = 0, dstY = dstY0; srcY < h; ++srcY, dstY += dstYIncr) {
T *srcPtr = (T *) (src->data + srcY * src->bytes_per_line);