latest changes from gta5sync

This commit is contained in:
Syping 2017-03-30 03:44:48 +02:00
parent c3643aece0
commit 6b4f856e4d
21 changed files with 569 additions and 451 deletions

View file

@ -69,6 +69,7 @@ void SnapmaticPicture::reset()
// INIT PIC
rawPicContent = "";
cachePicture = QImage();
jpegRawContentSizeE = 0;
jpegRawContentSize = 0;
picExportFileName = "";
isCustomFormat = 0;
@ -105,7 +106,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
if (!picFile->open(QFile::ReadOnly))
{
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(picFilePath);
picFile->deleteLater();
delete picFile;
return false;
}
@ -190,7 +190,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",1,NOHEADER";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -202,7 +201,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",2,NOHEADER";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -214,7 +212,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",2,NOJPEG";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -224,7 +221,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",2,NOPIC";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -232,6 +228,7 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
if (jpegRawContent.contains(QByteArray::fromHex("FFD9")))
{
int jpegRawContentSizeT = jpegRawContent.indexOf(QByteArray::fromHex("FFD9")) + 2;
jpegRawContentSizeE = jpegRawContentSizeT;
jpegRawContentSize = jpegRawContentSizeT;
if (jpegRawContent.contains(QByteArray::fromHex("FF454F49")))
{
@ -267,7 +264,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",3,NOJSON";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -275,7 +271,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",3,CTJSON";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -287,7 +282,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",4,NOTITL";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -295,7 +289,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",4,CTTITL";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -306,7 +299,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",5,NODESC";
picStream->close();
picStream->deleteLater();
delete picStream;
return picOk;
}
@ -314,7 +306,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
{
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(picFilePath) + ",5,CTDESC";
picStream->close();
picStream->deleteLater();
delete picStream;
return false;
}
@ -324,7 +315,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
updateStrings();
picStream->close();
picStream->deleteLater();
delete picStream;
if (!writeEnabled) { rawPicContent.clear(); }
return picOk;
@ -577,7 +567,6 @@ QImage SnapmaticPicture::getImage()
if (!picFile->open(QFile::ReadOnly))
{
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(picFilePath);
picFile->deleteLater();
delete picFile;
return QImage(0, 0, QImage::Format_RGB888);
}
@ -766,19 +755,12 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
// FILE MANAGEMENT
bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat)
bool SnapmaticPicture::exportPicture(const QString &fileName, const QString format)
{
QFile *picFile = new QFile(fileName);
if (picFile->open(QIODevice::WriteOnly))
{
if (!customFormat)
{
// Classic straight export
picFile->write(rawPicContent);
picFile->close();
picFile->deleteLater();
}
else
if (format == "G5E")
{
// Modern compressed export
QByteArray stockFileNameUTF8 = picFileName.toUtf8();
@ -801,7 +783,31 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat)
picFile->write("COM"); // Before Compressed
picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic
picFile->close();
picFile->deleteLater();
delete picFile;
}
else if (format == "JPG")
{
// JPEG export
QBuffer snapmaticStream(&rawPicContent);
snapmaticStream.open(QIODevice::ReadOnly);
if (snapmaticStream.seek(jpegStreamEditorBegin))
{
QByteArray jpegRawContent = snapmaticStream.read(jpegPicStreamLength);
if (jpegRawContentSizeE != 0)
{
jpegRawContent = jpegRawContent.left(jpegRawContentSizeE);
}
picFile->write(jpegRawContent);
}
picFile->close();
delete picFile;
}
else
{
// Classic straight export
picFile->write(rawPicContent);
picFile->close();
delete picFile;
}
return true;
}