On Mon, Jun 18, 2012 at 8:55 PM, Boris Zbarsky <firstname.lastname@example.org>
On 6/18/12 11:42 PM, Gregg Tavares (社用) wrote:
My understanding is getImageData is supposed to give you CSS pixels
ImageData objects must be initialized so that their width attribute
is set to w, the number of physical device pixels per row in the
image data, their height attribute is set to h, the number of rows
in the image data
and then much later:
Note: This implies that the data returned by getImageData() is at
the resolution of the canvas backing store. This is likely to not
be one device pixel to each CSS pixel if the display used is a
high resolution display.
I believe the claim was that Apple's implementation does in fact have this behavior.
Or in other words, per canvas spec if I have a <canvas width="100" height="100"> and I call getImageData(1, 3, 5, 7) on it and the backing store is using 2 device pixels per CSS pixel, then I will get an ImageData object whose .data Uint8ClampedArray of length 5*7*4 = 140 which represents the 10x14 piece of backing store whose top-left corner is at coordinates (2, 6) in the backing store pixel space (which are (1,3) in the CSS-pixel-based canvas coordinate space). The objects .width and .height will be 10 and 14 respectively.
Wow, what a crappy api. That's likely to break every page using getImageData and putImageData