Implement lanczos for upscaling to get crispier images

This commit is contained in:
Luis Ángel San Martín
2024-08-31 13:04:39 +02:00
parent a3f3149764
commit 819f456d6e
5 changed files with 401 additions and 27 deletions

View File

@ -16,6 +16,7 @@
#include "notifications_label_widget.h"
#include "comic_db.h"
#include "shortcuts_manager.h"
#include "resize_image.h"
#include "opengl_checker.h"
@ -387,16 +388,15 @@ void Viewer::updateContentSize()
if (zoom != 100) {
pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding);
}
// apply scaling
// apply size to the container
content->resize(pagefit);
// TODO: updtateContentSize should only scale the pixmap once
if (devicePixelRatioF() > 1) // only in HDPI displays
{
QPixmap page = currentPage->scaled(content->width() * devicePixelRatioF(), content->height() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
page.setDevicePixelRatio(devicePixelRatioF());
content->setPixmap(page);
}
// scale the image to fit the container
auto devicePixelRatioF = content->devicePixelRatioF();
QLOG_ERROR() << "src size: " << currentPage->size() << " content size: " << content->size() << " target size " << QSize(content->width() * devicePixelRatioF, content->height() * devicePixelRatioF);
QPixmap page = smartScalePixmap(*currentPage, content->width() * devicePixelRatioF, content->height() * devicePixelRatioF); // currentPage->scaled(content->width() * devicePixelRatioF(), content->height() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
page.setDevicePixelRatio(devicePixelRatioF);
content->setPixmap(page);
emit backgroundChanges();
}