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;
|
||||
jpegPicStreamLength = 524288;
|
||||
jsonStreamLength = 3076;
|
||||
tideStreamLength = 260;
|
||||
|
||||
// INIT PIC
|
||||
cachePicture = QImage(0, 0, QImage::Format_RGB32);
|
||||
|
@ -102,7 +103,7 @@ bool SnapmaticPicture::readingPicture()
|
|||
// Read JPEG Stream
|
||||
if (!picFile->isReadable())
|
||||
{
|
||||
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",3,NOPIC";
|
||||
lastStep = "2;/3,ReadingFile," + convertDrawStringForLog(picFileName) + ",2,NOPIC";
|
||||
picFile->close();
|
||||
picFile->deleteLater();
|
||||
delete picFile;
|
||||
|
@ -132,6 +133,44 @@ bool SnapmaticPicture::readingPicture()
|
|||
jsonStr = getSnapmaticJSONString(jsonRawContent);
|
||||
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->deleteLater();
|
||||
delete picFile;
|
||||
|
@ -154,6 +193,14 @@ QString SnapmaticPicture::getSnapmaticJSONString(QByteArray jsonBytes)
|
|||
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)
|
||||
{
|
||||
if (fileName != "")
|
||||
|
@ -172,6 +219,16 @@ void SnapmaticPicture::setPicture(QImage picture)
|
|||
cachePicture = picture;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureDesc()
|
||||
{
|
||||
return descStr;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureTitl()
|
||||
{
|
||||
return titlStr;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureStr()
|
||||
{
|
||||
return pictureStr;
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
QImage getPicture();
|
||||
QString getLastStep();
|
||||
QString getPictureStr();
|
||||
QString getPictureTitl();
|
||||
QString getPictureDesc();
|
||||
|
||||
// JSON
|
||||
bool isJsonOk();
|
||||
|
@ -50,12 +52,15 @@ public:
|
|||
private:
|
||||
QString getSnapmaticPictureString(QByteArray snapmaticHeader);
|
||||
QString getSnapmaticJSONString(QByteArray jsonBytes);
|
||||
QString getSnapmaticTIDEString(QByteArray tideBytes);
|
||||
QString convertDrawStringForLog(QString inputStr);
|
||||
QString convertLogStringForDraw(QString inputStr);
|
||||
QImage cachePicture;
|
||||
QString picFileName;
|
||||
QString pictureStr;
|
||||
QString lastStep;
|
||||
QString titlStr;
|
||||
QString descStr;
|
||||
bool picOk;
|
||||
|
||||
// PARSE INT
|
||||
|
@ -65,6 +70,7 @@ private:
|
|||
int jpegPreHeaderLength;
|
||||
int jpegPicStreamLength;
|
||||
int jsonStreamLength;
|
||||
int tideStreamLength;
|
||||
|
||||
// JSON
|
||||
void parseJsonContent();
|
||||
|
|
Loading…
Reference in a new issue