Remove unnecessary rendering

This commit is contained in:
Dávid Szabó 2016-08-26 01:38:07 +02:00 committed by Julian Descottes
parent f0f79754f1
commit bb7d5c862f
2 changed files with 6 additions and 1 deletions

View File

@ -134,6 +134,11 @@
return pskl.utils.FrameUtils.createFromImage(resizedImage);
},
createFromCanvas : function (canvas, x, y, w, h, preserveOpacity) {
var imgData = canvas.getContext('2d').getImageData(x, y, w, h).data;
return pskl.utils.FrameUtils.createFromImageData_(imgData, w, h, preserveOpacity);
},
/*
* Create a pskl.model.Frame from an Image object. By default transparent
* pixels will be converted to completely opaque or completely transparent

View File

@ -24,7 +24,7 @@
for (var i = 0 ; i < frameCount ; i++) {
context.clearRect(0, 0 , frameWidth, height);
context.drawImage(image, frameWidth * i, 0, frameWidth, height, 0, 0, frameWidth, height);
var frame = pskl.utils.FrameUtils.createFromImage(canvas);
var frame = pskl.utils.FrameUtils.createFromCanvas(canvas, 0, 0, frameWidth, height);
frames.push(frame);
}
return frames;