SnapmaticPicture: wrap getContentMaxLength
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
18083a3b0f
commit
2bb3f7f62d
6 changed files with 29 additions and 21 deletions
|
@ -607,7 +607,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
|
|||
if ((selectedFileName.left(4) == "PGTA" && !selectedFileName.contains('.')) || selectedFileName.right(4) == ".g5e")
|
||||
{
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
||||
if (picture->readingPicture(true, true, true))
|
||||
if (picture->readingPicture(true))
|
||||
{
|
||||
bool success = importSnapmaticPicture(picture, notMultiple);
|
||||
if (!success) delete picture;
|
||||
|
@ -678,7 +678,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
|
|||
else if (isSupportedImageFile(selectedFileName))
|
||||
{
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
|
||||
if (picture->readingPicture(true, false, true, false))
|
||||
if (picture->readingPicture(false))
|
||||
{
|
||||
if (!notMultiple)
|
||||
{
|
||||
|
@ -1048,7 +1048,7 @@ bool ProfileInterface::importRemote(QUrl remoteUrl)
|
|||
bool ProfileInterface::importImage(QImage *snapmaticImage, QDateTime importDateTime)
|
||||
{
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
|
||||
if (picture->readingPicture(true, false, true, false))
|
||||
if (picture->readingPicture(false))
|
||||
{
|
||||
bool success = false;
|
||||
ImportDialog *importDialog = new ImportDialog(profileName, this);
|
||||
|
|
|
@ -76,7 +76,7 @@ void ProfileLoader::run()
|
|||
emit loadingProgress(curFile, maximumV);
|
||||
QString picturePath = profileFolder % "/" % SnapmaticPic;
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
|
||||
if (picture->readingPicture(true, true, true))
|
||||
if (picture->readingPicture(true))
|
||||
{
|
||||
if (picture->isFormatSwitched())
|
||||
{
|
||||
|
|
|
@ -135,13 +135,13 @@ bool RagePhoto::load()
|
|||
size = dataBuffer.read(photoSize, 4);
|
||||
if (size != 4)
|
||||
return false;
|
||||
p_photoSize = charToUInt32LE(photoSize);
|
||||
quint32 t_photoSize = charToUInt32LE(photoSize);
|
||||
|
||||
char photoData[p_photoSize];
|
||||
size = dataBuffer.read(photoData, p_photoSize);
|
||||
if (size != p_photoSize)
|
||||
char photoData[t_photoSize];
|
||||
size = dataBuffer.read(photoData, t_photoSize);
|
||||
if (size != t_photoSize)
|
||||
return false;
|
||||
p_photoData = QByteArray(photoData, p_photoSize);
|
||||
p_photoData = QByteArray(photoData, t_photoSize);
|
||||
|
||||
dataBuffer.seek(p_jsonOffset + 264);
|
||||
char jsonMarker[4];
|
||||
|
@ -279,7 +279,6 @@ bool RagePhoto::load()
|
|||
return false;
|
||||
QByteArray t_photoData = QByteArray::fromRawData(compressedPhoto, i_photoSize);
|
||||
p_photoData = qUncompress(t_photoData);
|
||||
p_photoSize = p_photoData.size();
|
||||
|
||||
char jsonOffset[4];
|
||||
size = dataBuffer.read(jsonOffset, 4);
|
||||
|
@ -419,7 +418,8 @@ bool RagePhoto::setJsonData(const QByteArray &data)
|
|||
|
||||
bool RagePhoto::setPhotoData(const QByteArray &data)
|
||||
{
|
||||
if ((quint32)data.size() > p_photoSize)
|
||||
quint32 size = data.size();
|
||||
if (size > p_jpegBuffer)
|
||||
return false;
|
||||
p_photoData = data;
|
||||
return true;
|
||||
|
@ -427,7 +427,7 @@ bool RagePhoto::setPhotoData(const QByteArray &data)
|
|||
|
||||
bool RagePhoto::setPhotoData(const char *data, int size)
|
||||
{
|
||||
if ((quint32)size > p_photoSize)
|
||||
if ((quint32)size > p_jpegBuffer)
|
||||
return false;
|
||||
p_photoData = QByteArray(data, size);
|
||||
return true;
|
||||
|
@ -478,6 +478,11 @@ quint32 RagePhoto::photoBuffer()
|
|||
return p_jpegBuffer;
|
||||
}
|
||||
|
||||
quint32 RagePhoto::photoSize()
|
||||
{
|
||||
return p_photoData.size();
|
||||
}
|
||||
|
||||
RagePhoto::PhotoFormat RagePhoto::photoFormat()
|
||||
{
|
||||
return p_photoFormat;
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
const QString photoString();
|
||||
const QString title();
|
||||
quint32 photoBuffer();
|
||||
quint32 photoSize();
|
||||
PhotoFormat photoFormat();
|
||||
static RagePhoto* loadFile(const QString &filePath);
|
||||
|
||||
|
@ -85,7 +86,6 @@ private:
|
|||
quint32 p_headerSum;
|
||||
quint32 p_jpegBuffer;
|
||||
quint32 p_jsonOffset;
|
||||
quint32 p_photoSize;
|
||||
quint32 p_titlOffset;
|
||||
bool p_isLoaded;
|
||||
int p_inputMode;
|
||||
|
|
|
@ -112,11 +112,8 @@ bool SnapmaticPicture::preloadFile()
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bool fastLoad, bool lowRamMode_)
|
||||
bool SnapmaticPicture::readingPicture(bool cacheEnabled_)
|
||||
{
|
||||
Q_UNUSED(fastLoad)
|
||||
Q_UNUSED(lowRamMode_)
|
||||
Q_UNUSED(writeEnabled_)
|
||||
// Start opening file
|
||||
// lastStep is like currentStep
|
||||
|
||||
|
@ -166,12 +163,12 @@ void SnapmaticPicture::updateStrings()
|
|||
picExportFileName = exportStr % "_" % cmpPicTitl;
|
||||
}
|
||||
|
||||
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writeEnabled_, bool cacheEnabled_, bool fastLoad, bool lowRamMode_)
|
||||
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cacheEnabled_)
|
||||
{
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
picFilePath = fileName;
|
||||
return readingPicture(writeEnabled_, cacheEnabled_, fastLoad, lowRamMode_);
|
||||
return readingPicture(cacheEnabled_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -221,6 +218,11 @@ bool SnapmaticPicture::setPictureTitl(const QString &newTitle_)
|
|||
return false;
|
||||
}
|
||||
|
||||
int SnapmaticPicture::getContentMaxLength()
|
||||
{
|
||||
return ragePhoto.photoBuffer();
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getExportPictureFileName()
|
||||
{
|
||||
return picExportFileName;
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
~SnapmaticPicture();
|
||||
void reset();
|
||||
bool preloadFile();
|
||||
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
|
||||
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
|
||||
bool readingPictureFromFile(const QString &fileName, bool cacheEnabled = false);
|
||||
bool readingPicture(bool cacheEnabled = false);
|
||||
bool isPicOk(); // Please use isPictureOk instead
|
||||
void clearCache();
|
||||
QImage getImage(bool fastLoad = false);
|
||||
|
@ -73,6 +73,7 @@ public:
|
|||
QString getExportPictureFileName();
|
||||
QString getOriginalPictureFileName();
|
||||
QString getOriginalPictureFilePath();
|
||||
int getContentMaxLength();
|
||||
bool setImage(const QImage &picture);
|
||||
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
|
||||
bool setPictureStream(const QByteArray &streamArray);
|
||||
|
|
Loading…
Reference in a new issue