Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by xoriuz

hello all..

i just created new plugin for image manipulation, and have a problem to get the image pixels from canvas.

here is my code

getPixels: function(img) {
            var canvas = document.createElement('canvas');
            canvas.width = img.data.width;
            canvas.height = img.data.height;
            var context = canvas.getContext('2d');            
            context.drawImage(img.data);
            return context.getImageData(0,0,canvas.width,canvas.height);
},

"img" is instance of ig.Image


the problem is on
context.drawImage(img.data);

it always throw error: "Uncaught TypeError: Type error"

did i do something wrong?
please kindly advice

1 decade ago by monkeyArms

Think you need:


context.drawImage(img.data, 0, 0);
Page 1 of 1
« first « previous next › last »