putImageData() method can take the following additional, optional parameters:
putImageData(imagedata object, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight)
where:
- x,y = The starting point of the dirty rectangle in the CSS bitmap
- length = length of the dirty rectangle
- breath = breath of the dirty rectangle
If you provide the optional parameters, then the putImageData() method will take
only those pixels present inside the dirty rectangle and draw them on the canvas.
However, as of Gecko 1.9.1, the optional parameters remain unimplemented.
Notes:
1. If the canvas has images loaded from the hard disk and you try to access pixel
information using the getImageData() method, it will not work and will show a security
violation "NS_ERROR_DOM_SECURITY_ERR". This is because DOM will not allow accessing
pixel data to be accessed if the underlying image is from a different domain. When
the image comes from the hard disk, DOM does not know that the image is from the
same domain and hence throws the error. To test your code without running into this
error, run a local web server like apache, or test your code from the server
itself.
2. The getImageData() and putImageData() are expensive operations. So wherever possible,
find ways to get around using them.