W3C home > Mailing lists > Public > public-html@w3.org > June 2009

Re: Canvas getImageData with negative size violates invariant

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 12 Jun 2009 03:42:44 +0000 (UTC)
To: Philip Taylor <pjt47@cam.ac.uk>
Cc: HTML WG <public-html@w3.org>
Message-ID: <Pine.LNX.4.62.0906120341170.1648@hixie.dreamhostps.com>
On Sat, 30 May 2009, Philip Taylor wrote:
>
> The spec says:
> 
>   "the following must result in no visible changes to the rendering:
>    context.putImageData(context.getImageData(x, y, w, h), x, y);"
> 
> But if I write
> 
>    context.fillRect(0, 0, 10, 10);
>    var imgdata = context.getImageData(0, 10, 10, -10);
>    context.putImageData(imgdata, 0, 10);
> 
> then imgdata will contain the data from the rectangle (0,0)-(10,10) that was
> just filled (by the definition of getImageData), but will have imgdata.height
> = 10 (not -10) since that's the number of rows of image data. putImageData
> will then draw this data in the rectangle (0,10)-(10,20), and therefore will
> probably visibly change the rendering.
> 
> I think a more precise invariant is:
> 
>   context.putImageData(context.getImageData(x, y, w, h),
>     Math.min(x, x+w), Math.min(y, y+h));
> 
> but I don't know if there's a nicer way to fix the issue.

Fixed.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 12 June 2009 03:43:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:38 GMT