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

Jeff Muizelaar jmuizelaar at mozilla.com
Mon Sep 10 13:49:55 PDT 2012


On 2012-09-10, at 3:43 PM, Vladimir Vukicevic wrote:

> This is pretty tricky to get right -- there's just a general graphics
> problem in this case.  There are valid use cases for both sampling outside
> and not sampling outside the source rectangle, as well as implementation
> issues for being able to do source rectangle clamping.  For example, should
> you be able to take a source image and draw it scaled up using 4 rectangles
> (one for each quadrant) and have the result be equal to just doing it in
> one draw?  Or take any random subimage (for example, for efficient updates
> of some destination) and draw it in.
> 
> I do agree that the spec needs some clarity here, but I don't think that
> just stating that drawImage should always sample in the source is the right
> thing.  At best, I think a new mode toggle or flag would be needed to allow
> you to select.

FWIW, there are also negative performance implications to clamping samples to the source rect. Many graphics APIs do not support this kind sampling, and supporting this behaviour on top of those apis requires a temporary copy of the subimage to be made. 

-Jeff


More information about the whatwg mailing list