OSDN Git Service

pics: scale the image via QImageReader option and use its error string getter
authorIvailo Monev <xakepa10@gmail.com>
Mon, 14 Feb 2022 01:34:20 +0000 (03:34 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 14 Feb 2022 01:34:20 +0000 (03:34 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
pics/ksvgtopng.cpp

index b2599c1..58c1286 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include <QApplication>
+#include <QImageReader>
 #include <QImage>
 #include <QDebug>
 
@@ -45,14 +46,14 @@ int main(int argc, char **argv)
         return 2;
     }
 
-    QImage image(argv[3], "SVG");
+    QImageReader imagereader(argv[3], "SVG");
+    imagereader.setScaledSize(QSize(width, height));
+    QImage image = imagereader.read();
     if (image.isNull()) {
-        qWarning() << "Could not load" << argv[3];
+        qWarning() << "Cannot not read" << argv[3] << ":" << imagereader.errorString();
         return 3;
     }
 
-    image = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-
     if (image.save(argv[4], "PNG") == false) {
         qWarning() << "Could not save" << argv[4];
         return 4;