SnapmaticPicture: add eXtendMode
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Syping 2020-11-15 13:15:16 +01:00
parent c0a3e08527
commit 1b6cb511be
2 changed files with 11 additions and 5 deletions

View file

@ -171,7 +171,7 @@ bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cach
} }
} }
bool SnapmaticPicture::setImage(const QImage &picture) bool SnapmaticPicture::setImage(const QImage &picture, bool eXtendMode)
{ {
quint32 jpegPicStreamLength = p_ragePhoto.photoBuffer(); quint32 jpegPicStreamLength = p_ragePhoto.photoBuffer();
QByteArray picByteArray; QByteArray picByteArray;
@ -184,9 +184,15 @@ bool SnapmaticPicture::setImage(const QImage &picture)
saveSuccess = picture.save(&picStreamT, "JPEG", comLvl); saveSuccess = picture.save(&picStreamT, "JPEG", comLvl);
picStreamT.close(); picStreamT.close();
if (saveSuccess) { if (saveSuccess) {
if (static_cast<quint32>(picByteArrayT.length()) > jpegPicStreamLength) { quint32 size = picByteArrayT.length();
comLvl--; if (size > jpegPicStreamLength) {
saveSuccess = false; if (!eXtendMode) {
comLvl--;
saveSuccess = false;
}
else {
p_ragePhoto.setPhotoBuffer(size, true);
}
} }
else { else {
picByteArray = picByteArrayT; picByteArray = picByteArrayT;

View file

@ -74,7 +74,7 @@ public:
QString getOriginalPictureFileName(); QString getOriginalPictureFileName();
QString getOriginalPictureFilePath(); QString getOriginalPictureFilePath();
int getContentMaxLength(); int getContentMaxLength();
bool setImage(const QImage &picture); bool setImage(const QImage &picture, bool eXtendMode = false);
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
bool setPictureStream(const QByteArray &streamArray); bool setPictureStream(const QByteArray &streamArray);
void updateStrings(); void updateStrings();