W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2012

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

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 18 Dec 2012 11:42:39 +1300
Message-ID: <CAOp6jLYSA=czN558=bvAYjSbKjr-DX=p1dSYb6=uvjNj7zY7oA@mail.gmail.com>
To: Justin Novosad <junov@chromium.org>
Cc: Vladimir Vukicevic <vladimir@pobox.com>, Rik Cabanier <cabanier@gmail.com>, Kevin Gadd <kevin.gadd@gmail.com>, whatwg@lists.whatwg.org, Jeff Muizelaar <jmuizelaar@mozilla.com>, Ian Hickson <ian@hixie.ch>
On Tue, Dec 18, 2012 at 4:23 AM, Justin Novosad <junov@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
frame.

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? :-)

Rob
-- 
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]
Received on Monday, 17 December 2012 22:43:06 UTC

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