mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-24 14:23:36 -05:00
Merge pull request #2769 from defnax/thumbnailfixchannelpost
Fix transparency for channel post thumbnails
This commit is contained in:
commit
4cb36a5b69
@ -35,6 +35,7 @@
|
||||
#include "util/rsdir.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/RichTextEdit.h"
|
||||
#include "util/imageutil.h"
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
@ -607,11 +608,13 @@ bool CreateGxsChannelMsg::setThumbNail(const std::string& path, int frame){
|
||||
if(imageBuffer == NULL)
|
||||
return false;
|
||||
|
||||
QImage tNail(imageBuffer, width, height, QImage::Format_RGB32);
|
||||
QImage tNail(imageBuffer, width, height, QImage::Format_RGBA32);
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
bool has_transparency = ImageUtil::hasAlphaContent(tNail.toImage());
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
tNail.save(&buffer, "JPG");
|
||||
tNail.save(&buffer, has_transparency?"PNG":"JPG");
|
||||
QPixmap img;
|
||||
img.loadFromData(ba, "PNG");
|
||||
img = img.scaled(thumbnail_label->width(), thumbnail_label->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
@ -798,13 +801,17 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
RsGxsImage image;
|
||||
QPixmap pixmap;
|
||||
pixmap = preview_W->getCroppedScaledPicture();
|
||||
QImage qimg = pixmap.toImage();
|
||||
bool has_transparency = ImageUtil::hasAlphaContent(qimg);
|
||||
|
||||
if(!picture.isNull())
|
||||
{
|
||||
// send chan image
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user