QMovie: allow only one dimension to be used for scaledSize
In 4c21f72837 we did this for
QImageReader. So, to support the same for QMovie, we just need
to remove the custom (and very inefficient) scaling for frames.
This should be safe since the underlying QImageReader must ensure
that the returned image matches the scaled size.
[ChangeLog][QtGui][QMovie] Allow only one dimension (width
or height) to be set for the scaled size. In this case, the other
will be calculated automatically based on the original movie size
and maintaining the aspect ratio.
Fixes: QTBUG-115039
Change-Id: I50979a75970c79647dbb8c8b4b121266ba033a63
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
parent
23a906335e
commit
3924c945d1
|
|
@ -449,11 +449,7 @@ bool QMoviePrivate::next()
|
|||
}
|
||||
// Image and delay OK, update internal state
|
||||
currentFrameNumber = nextFrameNumber++;
|
||||
QSize scaledSize = reader->scaledSize();
|
||||
if (scaledSize.isValid() && (scaledSize != info.pixmap.size()))
|
||||
currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) );
|
||||
else
|
||||
currentPixmap = info.pixmap;
|
||||
currentPixmap = info.pixmap;
|
||||
|
||||
if (!speed)
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ private slots:
|
|||
#ifndef QT_NO_ICO
|
||||
void multiFrameImage();
|
||||
#endif
|
||||
|
||||
void setScaledSize_data();
|
||||
void setScaledSize();
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
|
|
@ -289,5 +292,33 @@ void tst_QMovie::multiFrameImage()
|
|||
}
|
||||
#endif
|
||||
|
||||
void tst_QMovie::setScaledSize_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
QTest::addColumn<QSize>("scaledSize");
|
||||
QTest::addColumn<QSize>("expectedSize");
|
||||
|
||||
QTest::newRow("trolltech (50, 50)") << QString("animations/trolltech.gif") << QSize(50, 50) << QSize(50, 50);
|
||||
QTest::newRow("trolltech (400, 400)") << QString("animations/trolltech.gif") << QSize(400, 400) << QSize(400, 400);
|
||||
QTest::newRow("trolltech (50, 0)") << QString("animations/trolltech.gif") << QSize(50, 0) << QSize(50, 25);
|
||||
QTest::newRow("trolltech (50, -1)") << QString("animations/trolltech.gif") << QSize(50, -1) << QSize(50, 25);
|
||||
QTest::newRow("trolltech (0, 50)") << QString("animations/trolltech.gif") << QSize(0, 50) << QSize(100, 50);
|
||||
QTest::newRow("trolltech (-1, 50)") << QString("animations/trolltech.gif") << QSize(-1, 50) << QSize(100, 50);
|
||||
}
|
||||
|
||||
void tst_QMovie::setScaledSize()
|
||||
{
|
||||
QFETCH(QString, fileName);
|
||||
QFETCH(QSize, scaledSize);
|
||||
QFETCH(QSize, expectedSize);
|
||||
|
||||
QMovie movie(QFINDTESTDATA(fileName));
|
||||
movie.setScaledSize(scaledSize);
|
||||
|
||||
movie.start();
|
||||
QCOMPARE(movie.currentFrameNumber(), 0);
|
||||
QCOMPARE(movie.currentImage().size(), expectedSize);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMovie)
|
||||
#include "tst_qmovie.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue