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

@ -22,8 +22,9 @@
#include "PostedGroupDialog.h"
#include "gui/gxs/GxsIdDetails.h"
#include "gui/common/FilesDefs.h"
#include "util/imageutil.h"
#include <retroshare/rswiki.h>
#include "retroshare/rswiki.h"
#include <iostream>
const uint32_t PostedCreateEnabledFlags = (
@ -104,8 +105,10 @@ void PostedGroupDialog::preparePostedGroup(RsPostedGroup &group, const RsGroupMe
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format
bool has_transparency = ImageUtil::hasAlphaContent(pixmap.toImage());
buffer.open(QIODevice::WriteOnly);
pixmap.save(&buffer, has_transparency?"PNG":"JPG"); // writes image into ba in PNG format
group.mGroupImage.copy((uint8_t *) ba.data(), ba.size());
} else {