Ignore too small page-canvases in PDFThumbnailView.setImage

It doesn't make sense to use a page-canvas that's *smaller* than the resulting thumbnail, since that causes the image to be upscaled which results in a blurry thumbnail. Note that this doesn't normally happen, unless a very small zoom-level is used in the viewer.
This commit is contained in:
Jonas Jenwald 2022-07-31 13:59:37 +02:00
parent b8aa9c6221
commit 5b50a50559

View File

@ -352,13 +352,17 @@ class PDFThumbnailView {
if (this.renderingState !== RenderingStates.INITIAL) {
return;
}
const { thumbnailCanvas: canvas, pdfPage } = pageView;
const { thumbnailCanvas: canvas, pdfPage, scale } = pageView;
if (!canvas) {
return;
}
if (!this.pdfPage) {
this.setPdfPage(pdfPage);
}
if (scale < this.scale) {
// Avoid upscaling the image, since that makes the thumbnail look blurry.
return;
}
this.renderingState = RenderingStates.FINISHED;
this._convertCanvasToImage(canvas);
}