mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Use better method of resizing images
This commit is contained in:
parent
fda6d7629a
commit
82bbdfb929
1 changed files with 7 additions and 7 deletions
|
@ -49,22 +49,22 @@ NotificationsManager::cacheImage(const mtx::events::collections::TimelineEvents
|
||||||
|
|
||||||
// delete any existing file content
|
// delete any existing file content
|
||||||
file.resize(0);
|
file.resize(0);
|
||||||
file.write(QByteArray(temp.data(), (int)temp.size()));
|
|
||||||
|
|
||||||
// resize the image (really inefficient, I know, but I can't find any
|
// resize the image
|
||||||
// better way right off
|
QImage img{utils::readImage(QByteArray{temp.data()})};
|
||||||
QImage img{path};
|
|
||||||
|
|
||||||
// delete existing contents
|
|
||||||
file.resize(0);
|
|
||||||
|
|
||||||
// make sure to save as PNG (because Plasma doesn't do JPEG in
|
// make sure to save as PNG (because Plasma doesn't do JPEG in
|
||||||
// notifications)
|
// notifications)
|
||||||
// if (!file.fileName().endsWith(".png"))
|
// if (!file.fileName().endsWith(".png"))
|
||||||
// file.rename(file.fileName() + ".png");
|
// file.rename(file.fileName() + ".png");
|
||||||
|
|
||||||
|
#ifdef NHEKO_DBUS_SYS // the images in D-Bus notifications are to be 200x100 max
|
||||||
img.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
img.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
||||||
.save(&file);
|
.save(&file);
|
||||||
|
#else
|
||||||
|
img.save(&file);
|
||||||
|
#endif // NHEKO_DBUS_SYS
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue