This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25635 - <canvas>: drawImage() should have a flag to treat subregions as surrounded by transparent black
Summary: <canvas>: drawImage() should have a flag to treat subregions as surrounded by...
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 enhancement
Target Milestone: Needs Impl Interest
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-09 19:01 UTC by Ian 'Hixie' Hickson
Modified: 2016-04-21 17:34 UTC (History)
3 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2014-05-09 19:01:30 UTC
drawImage():

"When the filtering algorithm requires a pixel value from outside the source rectangle but inside the original image data, then the value from the original image data must be used."

It would be useful for people drawing scaled sprites if instead this case used "the value from the nearest edge pixel" of the subregion being painted, same as with the edge of the image.
Comment 1 Justin Novosad 2014-05-09 20:18:45 UTC
Chrome has, at different times, implemented both clamping and non-clamping behaviors. Imposing either option makes some developers unhappy. There is definitely demand for adding an option for this.
Comment 2 Justin Novosad 2016-04-21 17:34:46 UTC
This is resolved with the ImageBitmap API.
createImageBitmap with the crop arguments achieves the desired behavior, and it can be implemented without making a copy of the underlying bitmap data (though that may not be the case in current implementations).