Skip to content

Commit 39184e1

Browse files
committed
Remove unnecessary downsampling drawing call.
1 parent 79ff77c commit 39184e1

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

js/load-image-scale.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@
255255
options
256256
)
257257
}
258-
canvas = document.createElement('canvas')
259258
downsamplingRatio = options.downsamplingRatio
260259
if (
261260
downsamplingRatio > 0 &&
@@ -264,6 +263,7 @@
264263
destHeight < sourceHeight
265264
) {
266265
while (sourceWidth * downsamplingRatio > destWidth) {
266+
canvas = document.createElement('canvas')
267267
canvas.width = sourceWidth * downsamplingRatio
268268
canvas.height = sourceHeight * downsamplingRatio
269269
loadImage.drawImage(
@@ -282,22 +282,10 @@
282282
sourceWidth = canvas.width
283283
sourceHeight = canvas.height
284284
// eslint-disable-next-line no-param-reassign
285-
img = document.createElement('canvas')
286-
img.width = sourceWidth
287-
img.height = sourceHeight
288-
loadImage.drawImage(
289-
canvas,
290-
img,
291-
0,
292-
0,
293-
sourceWidth,
294-
sourceHeight,
295-
sourceWidth,
296-
sourceHeight,
297-
options
298-
)
285+
img = canvas
299286
}
300287
}
288+
canvas = document.createElement('canvas')
301289
canvas.width = destWidth
302290
canvas.height = destHeight
303291
loadImage.transformCoordinates(canvas, options, data)

0 commit comments

Comments
 (0)