W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2008

[whatwg] More random comments on the putImageData definition

From: Robert O'Callahan <robert@ocallahan.org>
Date: Sun, 10 Feb 2008 21:41:34 +1300
Message-ID: <11e306600802100041s55824966mec9168f5eb4c64af@mail.gmail.com>
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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:39 UTC