mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-26 16:05:48 -04:00
FeedReader: Added shrink of images for board post
This commit is contained in:
parent
e25c148c27
commit
af562cb4ca
13 changed files with 226 additions and 14 deletions
|
@ -50,6 +50,8 @@
|
|||
#define IMG_ATTACH 0
|
||||
#define IMG_PICTURE 1
|
||||
|
||||
const int MAXMESSAGESIZE = 199000;
|
||||
|
||||
PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, const RsGxsId& default_author, QWidget *parent):
|
||||
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
|
||||
mPosted(posted), mGrpId(grpId),
|
||||
|
@ -226,7 +228,7 @@ void PostedCreatePostDialog::addPicture()
|
|||
}
|
||||
|
||||
QImage opt;
|
||||
if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff
|
||||
if (optimizeImage(image, imagebytes, opt)) {
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(opt));
|
||||
ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE);
|
||||
ui->removeButton->show();
|
||||
|
@ -274,7 +276,7 @@ void PostedCreatePostDialog::pastePicture()
|
|||
image = (qvariant_cast<QImage>(mimeData->imageData()));
|
||||
|
||||
QImage opt;
|
||||
if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff
|
||||
if (optimizeImage(image, imagebytes, opt)) {
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(opt));
|
||||
ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE);
|
||||
ui->removeButton->show();
|
||||
|
@ -287,6 +289,12 @@ void PostedCreatePostDialog::pastePicture()
|
|||
}
|
||||
}
|
||||
|
||||
bool PostedCreatePostDialog::optimizeImage(const QImage &image, QByteArray &imagebytes, QImage &imageOpt)
|
||||
{
|
||||
// Leave space for other stuff
|
||||
return ImageUtil::optimizeSizeBytes(imagebytes, image, imageOpt, "JPG", 640*480, MAXMESSAGESIZE - 2000);
|
||||
}
|
||||
|
||||
int PostedCreatePostDialog::viewMode()
|
||||
{
|
||||
if (ui->viewPostButton->isChecked()) {
|
||||
|
|
|
@ -45,10 +45,11 @@ public:
|
|||
void setNotes(const QString& notes);
|
||||
void setLink(const QString& link);
|
||||
|
||||
static bool optimizeImage(const QImage &image, QByteArray &imagebytes, QImage &imageOpt);
|
||||
|
||||
private:
|
||||
QString imagefilename;
|
||||
QByteArray imagebytes;
|
||||
const int MAXMESSAGESIZE = 199000;
|
||||
|
||||
private slots:
|
||||
void createPost();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue