Fix illegal memory access on simple image rotates
Clip the transformed and rounded sourceClip to the source rectangle, so we don't try to rotate pixels outside the source. Task-number: QTBUG-56252 Change-Id: Ib9cb80f9856724118867aea37ead0b02a6c71495 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
parent
e732e432ab
commit
f3ce959de6
@ -2273,6 +2273,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
|
|||||||
= QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(),
|
= QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(),
|
||||||
clippedTargetRect.width(), clippedTargetRect.height()).toRect();
|
clippedTargetRect.width(), clippedTargetRect.height()).toRect();
|
||||||
|
|
||||||
|
clippedSourceRect = clippedSourceRect.intersected(img.rect());
|
||||||
|
|
||||||
uint dbpl = d->rasterBuffer->bytesPerLine();
|
uint dbpl = d->rasterBuffer->bytesPerLine();
|
||||||
uint sbpl = img.bytesPerLine();
|
uint sbpl = img.bytesPerLine();
|
||||||
|
|
||||||
|
@ -307,6 +307,8 @@ private slots:
|
|||||||
|
|
||||||
void QTBUG50153_drawImage_assert();
|
void QTBUG50153_drawImage_assert();
|
||||||
|
|
||||||
|
void QTBUG56252();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillData();
|
void fillData();
|
||||||
void setPenColor(QPainter& p);
|
void setPenColor(QPainter& p);
|
||||||
@ -5078,6 +5080,23 @@ void tst_QPainter::QTBUG50153_drawImage_assert()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QPainter::QTBUG56252()
|
||||||
|
{
|
||||||
|
QImage sourceImage(1770, 1477, QImage::Format_RGB32);
|
||||||
|
QImage rotatedImage(1478, 1771, QImage::Format_RGB32);
|
||||||
|
QTransform transformCenter;
|
||||||
|
transformCenter.translate(739.0, 885.5);
|
||||||
|
transformCenter.rotate(270.0);
|
||||||
|
transformCenter.translate(-885.0, -738.5);
|
||||||
|
QPainter painter;
|
||||||
|
painter.begin(&rotatedImage);
|
||||||
|
painter.setTransform(transformCenter);
|
||||||
|
painter.drawImage(QPoint(0, 0),sourceImage);
|
||||||
|
painter.end();
|
||||||
|
|
||||||
|
// If no crash or illegal memory read, all is fine
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QPainter)
|
QTEST_MAIN(tst_QPainter)
|
||||||
|
|
||||||
#include "tst_qpainter.moc"
|
#include "tst_qpainter.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user