Degrade zoom image quality rather than failing
This commit is contained in:
parent
a8f6b27c48
commit
38f992d01d
|
@ -34,8 +34,12 @@ class ImageViewer {
|
||||||
this.hideLoadingIndicator();
|
this.hideLoadingIndicator();
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = this.img.naturalWidth * window.devicePixelRatio;
|
var pixelRatio = window.devicePixelRatio;
|
||||||
canvas.height = this.img.naturalHeight * 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);
|
canvas.getContext("2d").drawImage(this.img, 0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
const rect = this.img.getBoundingClientRect();
|
const rect = this.img.getBoundingClientRect();
|
||||||
|
|
Loading…
Reference in New Issue