From 502ff3e0191e41aebedae7ec1ce93f8c5a47e42b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 6 May 2020 14:55:34 -0500 Subject: [PATCH] Don't multiply by the device pixel ratio if that will put us over the canvas limit --- iOS/Resources/main_ios.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index f3cbd712f..885529894 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -35,10 +35,14 @@ class ImageViewer { this.hideLoadingIndicator(); var canvas = document.createElement("canvas"); - canvas.width = this.img.naturalWidth * window.devicePixelRatio; - canvas.height = this.img.naturalHeight * window.devicePixelRatio; + var pixelRatio = window.devicePixelRatio; + do { + canvas.width = this.img.naturalWidth * pixelRatio; + canvas.height = this.img.naturalHeight * pixelRatio; + pixelRatio--; + } while (pixelRatio > 0 && canvas.width * canvas.height > 16777216) canvas.getContext("2d").drawImage(this.img, 0, 0, canvas.width, canvas.height); - + const rect = this.img.getBoundingClientRect(); const message = { x: rect.x,