added TITL DESC parse in SnapmaticPicture class
This commit is contained in:
parent
b95a1cae68
commit
b682b46631
2 changed files with 64 additions and 1 deletions
|
@ -34,6 +34,7 @@ SnapmaticPicture::SnapmaticPicture(QString fileName, QObject *parent) : QObject(
|
||||||
jpegPreHeaderLength = 14;
|
jpegPreHeaderLength = 14;
|
||||||
jpegPicStreamLength = 524288;
|
jpegPicStreamLength = 524288;
|
||||||
jsonStreamLength = 3076;
|
jsonStreamLength = 3076;
|
||||||
|
tideStreamLength = 260;
|
||||||
|
|
||||||
// INIT PIC
|
// INIT PIC
|
||||||
cachePicture = QImage(0, 0, QImage::Format_RGB32);
|
cachePicture = QImage(0, 0, QImage::Format_RGB32);
|
||||||
|
@ -102,7 +103,7 @@ bool SnapmaticPicture::readingPicture()
|
||||||
// Read JPEG Stream
|
// Read JPEG Stream
|
||||||
if (!picFile->isReadable())
|
if (!picFile->isReadable())
|
||||||
{
|
{
|
||||||
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",3,NOPIC";
|
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",2,NOPIC";
|
||||||
picFile->close();
|
picFile->close();
|
||||||
picFile->deleteLater();
|
picFile->deleteLater();
|
||||||
delete picFile;
|
delete picFile;
|
||||||
|
@ -132,6 +133,44 @@ bool SnapmaticPicture::readingPicture()
|
||||||
jsonStr = getSnapmaticJSONString(jsonRawContent);
|
jsonStr = getSnapmaticJSONString(jsonRawContent);
|
||||||
parseJsonContent(); // JSON parsing is own function
|
parseJsonContent(); // JSON parsing is own function
|
||||||
|
|
||||||
|
if (!picFile->isReadable())
|
||||||
|
{
|
||||||
|
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",4,NOTITL";
|
||||||
|
picFile->close();
|
||||||
|
picFile->deleteLater();
|
||||||
|
delete picFile;
|
||||||
|
return picOk;
|
||||||
|
}
|
||||||
|
else if (picFile->read(4) != "TITL")
|
||||||
|
{
|
||||||
|
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",4,CTTITL";
|
||||||
|
picFile->close();
|
||||||
|
picFile->deleteLater();
|
||||||
|
delete picFile;
|
||||||
|
return picOk;
|
||||||
|
}
|
||||||
|
QByteArray titlRawContent = picFile->read(tideStreamLength);
|
||||||
|
titlStr = getSnapmaticTIDEString(titlRawContent);
|
||||||
|
|
||||||
|
if (!picFile->isReadable())
|
||||||
|
{
|
||||||
|
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",5,NODESC";
|
||||||
|
picFile->close();
|
||||||
|
picFile->deleteLater();
|
||||||
|
delete picFile;
|
||||||
|
return picOk;
|
||||||
|
}
|
||||||
|
else if (picFile->read(4) != "DESC")
|
||||||
|
{
|
||||||
|
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",5,CTDESC";
|
||||||
|
picFile->close();
|
||||||
|
picFile->deleteLater();
|
||||||
|
delete picFile;
|
||||||
|
return picOk;
|
||||||
|
}
|
||||||
|
QByteArray descRawContent = picFile->read(tideStreamLength);
|
||||||
|
descStr = getSnapmaticTIDEString(descRawContent);
|
||||||
|
|
||||||
picFile->close();
|
picFile->close();
|
||||||
picFile->deleteLater();
|
picFile->deleteLater();
|
||||||
delete picFile;
|
delete picFile;
|
||||||
|
@ -154,6 +193,14 @@ QString SnapmaticPicture::getSnapmaticJSONString(QByteArray jsonBytes)
|
||||||
return QString::fromLatin1(jsonUsefulBytes);
|
return QString::fromLatin1(jsonUsefulBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SnapmaticPicture::getSnapmaticTIDEString(QByteArray tideBytes)
|
||||||
|
{
|
||||||
|
QByteArray tideUsefulBytes = tideBytes;
|
||||||
|
tideUsefulBytes.remove(0,4);
|
||||||
|
QList<QByteArray> tideUsefulBytesList = tideUsefulBytes.split(0x00);
|
||||||
|
return QString::fromLatin1(tideUsefulBytesList.at(0));
|
||||||
|
}
|
||||||
|
|
||||||
bool SnapmaticPicture::readingPictureFromFile(QString fileName)
|
bool SnapmaticPicture::readingPictureFromFile(QString fileName)
|
||||||
{
|
{
|
||||||
if (fileName != "")
|
if (fileName != "")
|
||||||
|
@ -172,6 +219,16 @@ void SnapmaticPicture::setPicture(QImage picture)
|
||||||
cachePicture = picture;
|
cachePicture = picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SnapmaticPicture::getPictureDesc()
|
||||||
|
{
|
||||||
|
return descStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SnapmaticPicture::getPictureTitl()
|
||||||
|
{
|
||||||
|
return titlStr;
|
||||||
|
}
|
||||||
|
|
||||||
QString SnapmaticPicture::getPictureStr()
|
QString SnapmaticPicture::getPictureStr()
|
||||||
{
|
{
|
||||||
return pictureStr;
|
return pictureStr;
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
QImage getPicture();
|
QImage getPicture();
|
||||||
QString getLastStep();
|
QString getLastStep();
|
||||||
QString getPictureStr();
|
QString getPictureStr();
|
||||||
|
QString getPictureTitl();
|
||||||
|
QString getPictureDesc();
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
bool isJsonOk();
|
bool isJsonOk();
|
||||||
|
@ -50,12 +52,15 @@ public:
|
||||||
private:
|
private:
|
||||||
QString getSnapmaticPictureString(QByteArray snapmaticHeader);
|
QString getSnapmaticPictureString(QByteArray snapmaticHeader);
|
||||||
QString getSnapmaticJSONString(QByteArray jsonBytes);
|
QString getSnapmaticJSONString(QByteArray jsonBytes);
|
||||||
|
QString getSnapmaticTIDEString(QByteArray tideBytes);
|
||||||
QString convertDrawStringForLog(QString inputStr);
|
QString convertDrawStringForLog(QString inputStr);
|
||||||
QString convertLogStringForDraw(QString inputStr);
|
QString convertLogStringForDraw(QString inputStr);
|
||||||
QImage cachePicture;
|
QImage cachePicture;
|
||||||
QString picFileName;
|
QString picFileName;
|
||||||
QString pictureStr;
|
QString pictureStr;
|
||||||
QString lastStep;
|
QString lastStep;
|
||||||
|
QString titlStr;
|
||||||
|
QString descStr;
|
||||||
bool picOk;
|
bool picOk;
|
||||||
|
|
||||||
// PARSE INT
|
// PARSE INT
|
||||||
|
@ -65,6 +70,7 @@ private:
|
||||||
int jpegPreHeaderLength;
|
int jpegPreHeaderLength;
|
||||||
int jpegPicStreamLength;
|
int jpegPicStreamLength;
|
||||||
int jsonStreamLength;
|
int jsonStreamLength;
|
||||||
|
int tideStreamLength;
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
void parseJsonContent();
|
void parseJsonContent();
|
||||||
|
|
Loading…
Reference in a new issue