fix image downscaling (#4567)

This commit is contained in:
ebbit1q 2022-02-23 23:46:53 +01:00 committed by GitHub
parent 7108eb42c8
commit 217dc09c0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,13 +74,12 @@ QByteArray DlgEditAvatar::getImage()
return QByteArray(); return QByteArray();
} }
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
for (;;) { for (;;) {
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "JPG"); image.save(&buffer, "JPG");
if (ba.length() > MAX_FILE_LENGTH) { if (ba.length() > MAX_FILE_LENGTH) {
ba.clear();
image = image.scaledToWidth(image.width() / 2); // divide the amount of pixels in four to get the size down image = image.scaledToWidth(image.width() / 2); // divide the amount of pixels in four to get the size down
} else { } else {
return ba; return ba;