[whatwg] More random comments on the putImageData definition

On Jan 26, 2008 11:57 AM, Oliver Hunt <oliver at apple.com> wrote:

> Another thing that we need is some way to determine what the device
> pixel->css pixel ratio is.  Currently there's isn't even a real way to
> tell that it's 1:1 -- you would have do do a fillRect(width-1,
> height-1, 1, 1),; then getImageData(width-1, height-1, 1, 1) and see
> if they match.  Conceivably you could do this multiple times to
> estimate the ratio, but it would be non-trivial.
>

I think we have to be careful exposing that ratio to Web developers. With
the current ImageData spec it seems too easy for developers to assume a 1:1
ratio, notice that everything works in their tests, and deploy lots of
content which breaks when a browser tries to Do The Right Thing on some
other device, so we'll all just end up having to fix the ratio at 1:1 (or at
least do something equivalent for ImageData).

(Gecko 1.9 allows the ratio to vary in general for Web content, either due
to a high-DPI display device or due to user zooming, and things work pretty
well because there is no way for Web content to detect, or depend on, the
ratio. Unfortunately <canvas> doesn't currently change its internal buffer
size to match.)

So for ImageData, how about making the image data array have, by default,
one pixel value per canvas coordinate unit? If we really need to expose a
higher-resolution underlying buffer, then add an API to get the device-pixel
per canvas-coordinate-unit ratio, and extend createImageData and
getImageData so the ImageData array dimensions can be given as optional
extra parameters. Then it would be hard for an author to be surprised by an
unexpected ImageData array size.

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20080210/db9dbda2/attachment.htm>

Received on Sunday, 10 February 2008 00:41:34 UTC