mirror of
https://gitlab.com/Syping/gta5view-cmd
synced 2024-11-23 14:10:23 +01:00
usage of QImageReader
This commit is contained in:
parent
fef8e025ea
commit
3739338e0b
1 changed files with 17 additions and 2 deletions
19
main.cpp
19
main.cpp
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue