1
0
Fork 0
mirror of https://gitlab.com/Syping/gta5view-cmd synced 2024-11-23 06:00:22 +01:00

usage of QImageReader

This commit is contained in:
Syping 2018-02-03 00:59:27 +01:00
parent fef8e025ea
commit 3739338e0b

View file

@ -18,6 +18,7 @@
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QImageReader>
#include <QDateTime> #include <QDateTime>
#include <QPainter> #include <QPainter>
#include <QImage> #include <QImage>
@ -149,7 +150,21 @@ int main(int argc, char *argv[])
SnapmaticPicture picture(":/template.g5e"); SnapmaticPicture picture(":/template.g5e");
if (picture.readingPicture(true, false, true)) 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()) if (!image.isNull())
{ {
QSize snapmaticRes(960, 536); QSize snapmaticRes(960, 536);
@ -333,7 +348,7 @@ int main(int argc, char *argv[])
} }
else 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; return 1;
} }
} }