Skip to content

Commit 8285c8f

Browse files
committed
fix scale
1 parent b6d26f2 commit 8285c8f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

js/load-image.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
var height = img.naturalHeight || img.height
173173
var destWidth = width
174174
var destHeight = height
175+
var cropped = false
175176
var maxWidth
176177
var maxHeight
177178
var minWidth
@@ -276,15 +277,16 @@
276277
loadImage.renderImageToCanvas(
277278
canvas,
278279
img,
279-
sourceX,
280-
sourceY,
280+
cropped ? 0 : sourceX,
281+
cropped ? 0 : sourceY,
281282
sourceWidth,
282283
sourceHeight,
283284
0,
284285
0,
285286
canvas.width,
286287
canvas.height
287288
)
289+
cropped = true
288290
sourceWidth = canvas.width
289291
sourceHeight = canvas.height
290292
img = document.createElement('canvas')
@@ -313,8 +315,8 @@
313315
return loadImage.renderImageToCanvas(
314316
canvas,
315317
img,
316-
sourceX,
317-
sourceY,
318+
cropped ? 0 : sourceX,
319+
cropped ? 0 : sourceY,
318320
sourceWidth,
319321
sourceHeight,
320322
0,

0 commit comments

Comments
 (0)