mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Use the new resize image API to resize the pages while reading
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "continuous_page_widget.h"
|
||||
#include "continuous_view_model.h"
|
||||
#include "render.h"
|
||||
#include "resize_image.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
@ -183,7 +184,8 @@ const QImage *ContinuousPageWidget::scaledImageForPaint(int pageIndex, const QIm
|
||||
entry.sourceCacheKey = sourceKey;
|
||||
entry.sourceSize = source->size();
|
||||
entry.targetSize = targetSize;
|
||||
entry.scaledImage = source->scaled(targetSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
entry.scaledImage = scaleImage(*source, targetSize.width(), targetSize.height(),
|
||||
Configuration::getConfiguration().getScalingMethod());
|
||||
scaledPageCache.pages.insert(pageIndex, std::move(entry));
|
||||
|
||||
return &scaledPageCache.pages[pageIndex].scaledImage;
|
||||
|
||||
@ -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());
|
||||
// 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user