mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
prioritize optimized cases in QImage::transformed()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
aa7ff8fd4e
commit
0861282369
1 changed files with 16 additions and 15 deletions
|
@ -4575,14 +4575,23 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
|
|||
|
||||
// compute size of target image
|
||||
QTransform mat = trueMatrix(matrix, ws, hs);
|
||||
bool complex_xform = false;
|
||||
bool scale_xform = false;
|
||||
if (mat.type() <= QTransform::TxScale) {
|
||||
if (mat.type() == QTransform::TxNone) // identity matrix
|
||||
return *this;
|
||||
else if (mat.m11() == -1. && mat.m22() == -1.)
|
||||
return rotated180(*this);
|
||||
|
||||
if (mat.type() == QTransform::TxNone) {
|
||||
// identity matrix
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (mat.type() == QTransform::TxRotate) {
|
||||
if (mat.m11() == 0 && mat.m12() == 1.0 && mat.m21() == -1. && mat.m22() == 0)
|
||||
return rotated90(*this);
|
||||
else if (mat.m11() == 0 && mat.m12() == -1.0 && mat.m21() == 1.0 && mat.m22() == 0 )
|
||||
return rotated270(*this);
|
||||
else if (mat.m11() == -1.0 && mat.m12() == 0 && mat.m21() == 0 && mat.m22() == -1.0)
|
||||
return rotated180(*this);
|
||||
}
|
||||
|
||||
bool complex_xform = false;
|
||||
if (mat.type() == QTransform::TxScale) {
|
||||
if (mode == Qt::FastTransformation) {
|
||||
hd = qRound(qAbs(mat.m22()) * hs);
|
||||
wd = qRound(qAbs(mat.m11()) * ws);
|
||||
|
@ -4590,15 +4599,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
|
|||
hd = int(qAbs(mat.m22()) * hs + 0.9999);
|
||||
wd = int(qAbs(mat.m11()) * ws + 0.9999);
|
||||
}
|
||||
scale_xform = true;
|
||||
} else {
|
||||
if (mat.type() <= QTransform::TxRotate && mat.m11() == 0 && mat.m22() == 0) {
|
||||
if (mat.m12() == 1. && mat.m21() == -1.)
|
||||
return rotated90(*this);
|
||||
else if (mat.m12() == -1. && mat.m21() == 1.)
|
||||
return rotated270(*this);
|
||||
}
|
||||
|
||||
QPolygonF a(QRectF(0, 0, ws, hs));
|
||||
a = mat.map(a);
|
||||
QRect r = a.boundingRect().toAlignedRect();
|
||||
|
|
Loading…
Add table
Reference in a new issue