From 3739338e0bdf803102ee442118b0be8bd1103f15 Mon Sep 17 00:00:00 2001 From: Syping Date: Sat, 3 Feb 2018 00:59:27 +0100 Subject: [PATCH] usage of QImageReader --- main.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index bf86bb0..4acc36d 100644 --- a/main.cpp +++ b/main.cpp @@ -18,6 +18,7 @@ #include "SnapmaticPicture.h" #include +#include #include #include #include @@ -149,7 +150,21 @@ int main(int argc, char *argv[]) SnapmaticPicture picture(":/template.g5e"); if (picture.readingPicture(true, false, true)) { - QImage image(args.at(1)); + QImage image; + QFile imageFile(args.at(1)); + if (!imageFile.open(QFile::ReadOnly)) + { + cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " failed!" << endl; + return 1; + } + QImageReader imageReader; + imageReader.setDecideFormatFromContent(true); + imageReader.setDevice(&imageFile); + if (!imageReader.read(&image)) + { + cout << "gta5view-cmd: Parsing of " << args.at(1).toStdString().c_str() << " failed!" << endl; + return 1; + } if (!image.isNull()) { QSize snapmaticRes(960, 536); @@ -333,7 +348,7 @@ int main(int argc, char *argv[]) } else { - cout << "gta5view-cmd: Reading of " << args.at(1).toStdString().c_str() << " failed!" << endl; + cout << "gta5view-cmd: " << args.at(1).toStdString().c_str() << " is invalid image!" << endl; return 1; } }