Use the new resize image API to resize the pages while reading

This commit is contained in:
luisangelsm
2026-03-06 17:18:14 +01:00
parent 80de46ce74
commit de676a0fcb
2 changed files with 13 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#include "viewer.h"
#include "continuous_page_widget.h"
#include "continuous_view_model.h"
#include "resize_image.h"
#include "configuration.h"
#include "magnifying_glass.h"
#include "goto_flow_widget.h"
@ -433,16 +434,17 @@ 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 pixmap to physical pixels for crisp rendering on all displays
auto dpr = devicePixelRatioF();
QPixmap page = scalePixmap(*currentPage,
qRound(content->width() * dpr),
qRound(content->height() * dpr),
Configuration::getConfiguration().getScalingMethod());
page.setDevicePixelRatio(dpr);
content->setPixmap(page);
emit backgroundChanges();
}