From 7707aca03e01203f81de733a11b5da8ec4d1e3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Szab=C3=B3?= Date: Thu, 25 Aug 2016 20:20:10 +0200 Subject: [PATCH] Change nested loop and directly change pixels --- src/js/utils/FrameUtils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/utils/FrameUtils.js b/src/js/utils/FrameUtils.js index af2c74e8..c338d852 100644 --- a/src/js/utils/FrameUtils.js +++ b/src/js/utils/FrameUtils.js @@ -121,11 +121,11 @@ mergeFrames_ : function (frameA, frameB) { var transparentColorInt = pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR); - frameB.forEachPixel(function (color, col, row) { - if (color != transparentColorInt) { - frameA.setPixel(col, row, color); + for (var i = 0, length = frameA.getWidth() * frameA.getHeight(); i < length; ++i) { + if (frameB.pixels[i] != transparentColorInt && frameA.pixels[i] != frameB.pixels[i]) { + frameA.pixels[i] = frameB.pixels[i]; } - }); + } }, resize : function (frame, targetWidth, targetHeight, smoothing) {