I am trying out a sample code that converts a color image to grey scale on a canvas in WebOS (enyo). When I use the ctx.getImageData method to read the pixels, the imageData contains only zeros. The sample I am using is provided in the link below:
Does WebOS support reading pixel data from canvas? Am I doing something wrong here?
I have refered to the following link for the logic and the code:
This works fine.
you should move the getimagedata in the callback from the onload event of the image.
something like:
and set the source after binding the event
to avoid a racing condition
now the imagedata is retrieved before the actual pixels are loaded. Which results in an empty array.