You may call
context.getImageData(0, 0, context.canvas.width, context.canvas.height);
which will return an ImageData object. This has a property called data of type CanvasPixelArray that contains the rgb and transparency values ββof all pixels. These values ββare not references to the canvas, so they can be changed without affecting the canvas.
If you need a copy of the element, you can create a new canvas element and then copy all the attributes to the new canvas element. After that you can use
context.putImageData(imageData, 0, 0);
to draw an ImageData object on a new canvas element.
See this getPixel answer from HTML Canvas for more details ? for pixel management.
You can find this mozilla article useful as well as https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Drawing_shapes
Castrohenge Jul 23 '10 at 16:16 2010-07-23 16:16
source share