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

View file

@ -74,7 +74,7 @@ public:
QString getOriginalPictureFileName();
QString getOriginalPictureFilePath();
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 setPictureStream(const QByteArray &streamArray);
void updateStrings();