MxcImageProvider: Only use scaledToHeight if width <= 0.

This commit is contained in:
tastytea 2021-12-27 22:59:51 +01:00
parent 7086e23bdd
commit 5ac1195402
No known key found for this signature in database
GPG Key ID: CFC39497F1B26E07
1 changed files with 8 additions and 2 deletions

View File

@ -124,8 +124,11 @@ MxcImageProvider::download(const QString &id,
if (fileInfo.exists()) { if (fileInfo.exists()) {
QImage image = utils::readImageFromFile(fileInfo.absoluteFilePath()); QImage image = utils::readImageFromFile(fileInfo.absoluteFilePath());
if (!image.isNull()) { if (!image.isNull()) {
if (requestedSize != image.size()) { if (requestedSize.width() <= 0) {
image = image.scaledToHeight(requestedSize.height(), Qt::SmoothTransformation); image = image.scaledToHeight(requestedSize.height(), Qt::SmoothTransformation);
} else {
image =
image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
} }
if (radius != 0) { if (radius != 0) {
@ -157,9 +160,12 @@ MxcImageProvider::download(const QString &id,
auto data = QByteArray(res.data(), (int)res.size()); auto data = QByteArray(res.data(), (int)res.size());
QImage image = utils::readImage(data); QImage image = utils::readImage(data);
if (!image.isNull()) { if (!image.isNull()) {
if (requestedSize != image.size()) { if (requestedSize.width() <= 0) {
image = image =
image.scaledToHeight(requestedSize.height(), Qt::SmoothTransformation); image.scaledToHeight(requestedSize.height(), Qt::SmoothTransformation);
} else {
image =
image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
} }
if (radius != 0) { if (radius != 0) {