Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
470005c7 by Benjamin Arnaud at 2022-06-20T07:43:50+00:00
qt/covergenerator: Restore QImage::scaled implementation

QImage::scaled provides a better quality compared to 
QImageReader::setScaledSize.
Except for svg(s).

This implementation that was removed in a prior commit should stay relevant in 
the future.

- - - - -


1 changed file:

- modules/gui/qt/util/covergenerator.cpp


Changes:

=====================================
modules/gui/qt/util/covergenerator.cpp
=====================================
@@ -234,8 +234,31 @@ void CoverGenerator::drawImage(QPainter & painter, const 
QString & fileName, con
     QSize size = reader.size().scaled(target.width(),
                                       target.height(), 
Qt::KeepAspectRatioByExpanding);
 
-    reader.setScaledSize(size);
-    QImage image = reader.read();
+    QImage image;
+
+    // NOTE: QImage::scaled provides a better quality compared to 
QImageReader::setScaledSize.
+    //       Except for svg(s).
+    if (fileName.endsWith(".svg", Qt::CaseInsensitive))
+    {
+        if (size.isEmpty() == false)
+        {
+            reader.setScaledSize(size);
+        }
+
+        if (reader.read(&image) == false)
+            return;
+    }
+    else
+    {
+        if (reader.read(&image) == false)
+            return;
+
+        if (size.isEmpty() == false)
+        {
+            // NOTE: We are using Qt::SmoothTransformation to favor quality.
+            image = image.scaled(size, Qt::IgnoreAspectRatio, 
Qt::SmoothTransformation);
+        }
+    }
 
     int x = std::ceil((image.width() - target.width()) / 2.);
     int y = std::ceil((image.height() - target.height()) / 2.);



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/470005c71dcef599ad003ddfab3767a336e40117

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/470005c71dcef599ad003ddfab3767a336e40117
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to