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_page_widget.h"
|
||||||
#include "continuous_view_model.h"
|
#include "continuous_view_model.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
#include "resize_image.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
@ -183,7 +184,8 @@ const QImage *ContinuousPageWidget::scaledImageForPaint(int pageIndex, const QIm
|
|||||||
entry.sourceCacheKey = sourceKey;
|
entry.sourceCacheKey = sourceKey;
|
||||||
entry.sourceSize = source->size();
|
entry.sourceSize = source->size();
|
||||||
entry.targetSize = targetSize;
|
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));
|
scaledPageCache.pages.insert(pageIndex, std::move(entry));
|
||||||
|
|
||||||
return &scaledPageCache.pages[pageIndex].scaledImage;
|
return &scaledPageCache.pages[pageIndex].scaledImage;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "viewer.h"
|
#include "viewer.h"
|
||||||
#include "continuous_page_widget.h"
|
#include "continuous_page_widget.h"
|
||||||
#include "continuous_view_model.h"
|
#include "continuous_view_model.h"
|
||||||
|
#include "resize_image.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "magnifying_glass.h"
|
#include "magnifying_glass.h"
|
||||||
#include "goto_flow_widget.h"
|
#include "goto_flow_widget.h"
|
||||||
@ -433,16 +434,17 @@ void Viewer::updateContentSize()
|
|||||||
if (zoom != 100) {
|
if (zoom != 100) {
|
||||||
pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding);
|
pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding);
|
||||||
}
|
}
|
||||||
// apply scaling
|
// apply size to the container
|
||||||
content->resize(pagefit);
|
content->resize(pagefit);
|
||||||
|
|
||||||
// TODO: updtateContentSize should only scale the pixmap once
|
// scale the pixmap to physical pixels for crisp rendering on all displays
|
||||||
if (devicePixelRatioF() > 1) // only in HDPI displays
|
auto dpr = devicePixelRatioF();
|
||||||
{
|
QPixmap page = scalePixmap(*currentPage,
|
||||||
QPixmap page = currentPage->scaled(content->width() * devicePixelRatioF(), content->height() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
qRound(content->width() * dpr),
|
||||||
page.setDevicePixelRatio(devicePixelRatioF());
|
qRound(content->height() * dpr),
|
||||||
|
Configuration::getConfiguration().getScalingMethod());
|
||||||
|
page.setDevicePixelRatio(dpr);
|
||||||
content->setPixmap(page);
|
content->setPixmap(page);
|
||||||
}
|
|
||||||
|
|
||||||
emit backgroundChanges();
|
emit backgroundChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user