[whatwg] I believe source rectangles for HTML5 Canvas drawImage are specified incorrectly

Robert O'Callahan robert at ocallahan.org
Mon Dec 17 14:42:39 PST 2012

On Tue, Dec 18, 2012 at 4:23 AM, Justin Novosad <junov at chromium.org> wrote:

> This gives me another
> idea: we could just have a new Image constructor that creates a new image
> element that is a subregion of another:
> var mySprite = new Image(spriteMap, x, y, w, h);
> This can be implemented in a lightweight way that just references the data
> of the source image.

I like this idea. It means that implementations that need to make a copy of
the data can make a copy and associate it with the new Image object ---
which seems more straightforward than a drawSubimage call, where such
implementations would have to cache subimages internally.

This approach also avoids having to define how subimages would behave for
video elements, canvases, etc.

This approach is also more generally useful than a drawSubimage call or a
new drawImage parameter.

We would have to define how this subimage constructor works for an animated
image. I suggest it should return a non-animated subimage of the first

I think the main risk of this approach is that it requires Web apps to opt
into it instead of changing the spec to match what Chrome is currently
doing, so it doesn't solve the immediate problem of Web apps that currently
work in Chrome not working in other browsers. Chrome changing behavior to
match the spec would solve this. Can that happen quickly, please? :-)

Jesus called them together and said, “You know that the rulers of the
Gentiles lord it over them, and their high officials exercise authority
over them. Not so with you. Instead, whoever wants to become great among
you must be your servant, and whoever wants to be first must be your
slave — just
as the Son of Man did not come to be served, but to serve, and to give his
life as a ransom for many.” [Matthew 20:25-28]

More information about the whatwg mailing list