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

[whatwg] createImageData -> new ImageData() ?

From: Kornel Lesinski <kornel@osiolki.net>
Date: Tue, 12 Feb 2008 22:07:38 -0000
Message-ID: <op.t6fme5n04suneb@aimac.local>
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  

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  

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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:00 UTC