[whatwg] createImageData -> new ImageData() ?

On Sun, 10 Feb 2008 23:25:51 -0000, Ian Hickson <ian at hixie.ch> wrote:

>> That would mean that passing ImageData around between two <canvas>
>> elements doesn't always work as expected. I think that's highly
>> undesirable. Is there any implementation where we know this will the
>> case?
>
> Not today, but why preclude it? Implementations could get higher quality
> renderings on canvases that get resized dynamically, by using a bigger
> backing store. What's wrong with what we have now?

It's very easy to write code which assumes that size of imageData is the  
same as size given in <canvas width height> (I know, because I did it :)

Since the ratio is system/browser-dependent and 200dpi screens aren't  
popular yet, such bug may be easily overlooked/ignored and get widely  
deployed.

The difference in sizes isn't intuitive. For example if browser doubled  
number of pixels in ImageData only when user used zoom, I think authors  
would rather think that browser's zoom is buggy.

I think that by default getImageData should return data with same size as  
specified in width/height attributes of <canvas>. There might be another  
method (getImageScreenData?) or method argument that returns all pixels of  
<canvas>.

ImageData can be made portable between canvases by adding aspect ratio  
field or additional width/height fields given in CSS pixels.

-- 
regards, Kornel Lesi?ski

Received on Tuesday, 12 February 2008 14:07:38 UTC