mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-03 13:43:03 -04:00
Fix transparency for channel post thumbnails
This commit is contained in:
parent
17562e727e
commit
1efed9d436
1 changed files with 8 additions and 4 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
#include "util/qtthreadsutils.h"
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/RichTextEdit.h"
|
#include "util/RichTextEdit.h"
|
||||||
|
#include "util/imageutil.h"
|
||||||
|
|
||||||
#include <retroshare/rsfiles.h>
|
#include <retroshare/rsfiles.h>
|
||||||
|
|
||||||
|
@ -610,8 +611,10 @@ bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){
|
||||||
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
|
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QBuffer buffer(&ba);
|
QBuffer buffer(&ba);
|
||||||
|
bool has_transparency = ImageUtil::hasAlphaContent(tNail.toImage());
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
tNail.save(&buffer, "JPG");
|
tNail.save(&buffer, has_transparency?"PNG":"JPG");
|
||||||
QPixmap img;
|
QPixmap img;
|
||||||
img.loadFromData(ba, "PNG");
|
img.loadFromData(ba, "PNG");
|
||||||
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
@ -797,15 +800,16 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QBuffer buffer(&ba);
|
QBuffer buffer(&ba);
|
||||||
|
|
||||||
RsGxsImage image;
|
RsGxsImage image;
|
||||||
|
bool has_transparency = ImageUtil::hasAlphaContent(picture.toImage());
|
||||||
|
|
||||||
if(!picture.isNull())
|
if(!picture.isNull())
|
||||||
{
|
{
|
||||||
// send chan image
|
// send chan image
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
preview_W->getCroppedScaledPicture().save(&buffer, "JPG"); // writes image into ba in PNG format
|
preview_W->getCroppedScaledPicture().save(&buffer, has_transparency?"PNG":"JPG"); // writes image into ba in PNG format
|
||||||
image.copy((uint8_t *) ba.data(), ba.size());
|
image.copy((uint8_t *) ba.data(), ba.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string error_string;
|
std::string error_string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue