diff options
author | JiDe Zhang <zhangjide@uniontech.com> | 2022-07-27 18:04:30 +0800 |
---|---|---|
committer | JiDe Zhang <zhangjide@uniontech.com> | 2022-08-18 10:40:42 +0800 |
commit | a6b55b3c46cf47d560e10a4b69db24a475261546 (patch) | |
tree | a7303a6d13a3266d2cc619e33436b6426225c257 /tests/auto/gui/image/qimage | |
parent | 371214dea7f92b3170d0239b3d9944275adf951a (diff) |
Allow specify distance to plane for QTransform
The default camera to plane distance is 1024, when rotating a big image
along the x or y axis, some areas of the screen may move above the
camera, causing the rotation to fail. A new rotation interface has been
added to allow users to specify the distance from the camera to the
plane themselves when rotating the QImage. Also, this support has been
added to QMatrix4x4::projectedRotate.
[ChangeLog][QtGui][QTransform] Added overloads to rotate() and
rotateRadians() that allow specifying of the distance to the rotation
plane.
Fixes: QTBUG-105088
Change-Id: I81f629916ddd9b6ab84e0282191e4284a88a85f5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/gui/image/qimage')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 898345e44a..9842fd36be 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -4,6 +4,7 @@ #include <QTest> #include <QBuffer> +#include <QMatrix4x4> #include <qimage.h> #include <qimagereader.h> @@ -67,6 +68,7 @@ private slots: void rotate_data(); void rotate(); + void rotateBigImage(); void copy(); @@ -1212,6 +1214,23 @@ void tst_QImage::rotate() QCOMPARE(original, dest); } +void tst_QImage::rotateBigImage() +{ + // QTBUG-105088 + QImage big_image(3840, 2160, QImage::Format_ARGB32_Premultiplied); + QTransform t; + t.translate(big_image.width() / 2.0, big_image.height() / 2.0); + t.rotate(-89, Qt::YAxis, big_image.width()); + t.translate(-big_image.width() / 2.0, -big_image.height() / 2.0); + QVERIFY(!big_image.transformed(t).isNull()); + + QMatrix4x4 m; + m.translate(big_image.width() / 2.0, big_image.height() / 2.0); + m.projectedRotate(89, 0, 1, 0, big_image.width()); + m.translate(-big_image.width() / 2.0, -big_image.height() / 2.0); + QVERIFY(!big_image.transformed(m.toTransform()).isNull()); +} + void tst_QImage::copy() { // Task 99250 |