added auto-choose of image format when transparency is present

This commit is contained in:
csoler 2023-01-16 22:11:44 +01:00
parent de1b8f08d2
commit 7aacfb9aef
6 changed files with 47 additions and 23 deletions

View file

@ -40,6 +40,7 @@
#include "util/misc.h"
#include "gui/common/FilesDefs.h"
#include "util/HandleRichText.h"
#include "util/imageutil.h"
#include "retroshare/rsinit.h"
#define ICONNAME "groupicon.png"
@ -138,10 +139,11 @@ void AvatarDialog::getAvatar(QByteArray &avatar)
return;
}
QBuffer buffer(&avatar);
bool has_transparency = ImageUtil::hasAlphaContent(pixmap.toImage());
QBuffer buffer(&avatar);
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format
pixmap.save(&buffer, has_transparency?"PNG":"JPG"); // writes image into ba in PNG format
}
void AvatarDialog::load()