[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] How to set a canvas backing store to display units?





On Mon, Jun 18, 2012 at 8:55 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

On 6/18/12 11:42 PM, Gregg Tavares (çç) wrote:
My understanding is getImageData is supposed to give you CSS pixels

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-getimagedata says:

Â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.

It sounds to me like they're not doing that:Âhttp://lists.w3.org/Archives/Public/public-whatwg-archive/2012Mar/0179.html

Or maybe they changed their minds.Â

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.

Now the canvas spec doesn't define what size backing store the UA is to use, of course; in practice Gecko always sizes the backing store so that one backing store pixel is one CSS pixel, precisely to avoid issues with scripts using imageData.....


-Boris

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------