diff --git a/src/core/image_resizer.js b/src/core/image_resizer.js index ae0d43fa2..c38169199 100644 --- a/src/core/image_resizer.js +++ b/src/core/image_resizer.js @@ -193,8 +193,13 @@ class ImageResizer { for (const step of steps) { const prevWidth = newWidth; const prevHeight = newHeight; - newWidth = Math.floor(newWidth / step); - newHeight = Math.floor(newHeight / step); + + // See bug 1820511 (Windows specific bug). + // TODO: once the above bug is fixed we could revert to: + // newWidth = Math.floor(newWidth / 2); + newWidth = Math.floor(newWidth / step) - 1; + newHeight = Math.floor(newHeight / step) - 1; + const canvas = new OffscreenCanvas(newWidth, newHeight); const ctx = canvas.getContext("2d"); ctx.drawImage( diff --git a/src/display/canvas.js b/src/display/canvas.js index 74da9d151..8a0757285 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1313,11 +1313,21 @@ class CanvasGraphics { let newWidth = paintWidth, newHeight = paintHeight; if (widthScale > 2 && paintWidth > 1) { - newWidth = Math.ceil(paintWidth / 2); + // See bug 1820511 (Windows specific bug). + // TODO: once the above bug is fixed we could revert to: + // newWidth = Math.ceil(paintWidth / 2); + newWidth = + paintWidth >= 16384 + ? Math.floor(paintWidth / 2) - 1 || 1 + : Math.ceil(paintWidth / 2); widthScale /= paintWidth / newWidth; } if (heightScale > 2 && paintHeight > 1) { - newHeight = Math.ceil(paintHeight / 2); + // TODO: see the comment above. + newHeight = + paintHeight >= 16384 + ? Math.floor(paintHeight / 2) - 1 || 1 + : Math.ceil(paintHeight) / 2; heightScale /= paintHeight / newHeight; } tmpCanvas = this.cachedCanvases.getCanvas(