You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
drawImage() with a density-corrected img: image pixels or CSS pixels? #13074
If not specified, the dw and dh arguments must default to the values of sw and sh, interpreted such that one CSS pixel in the image is treated as one unit in the output bitmap's coordinate space. If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's natural width in image pixels, and the image's natural height in image pixels, respectively.
For an img whose density isn't 1 (from srcset or EXIF resolution), image pixels and CSS pixels differ, and it's unclear which one the source rectangle uses or what size drawImage(img, 0, 0) draws at. My reading is that it draws at the density-corrected natural size (naturalWidth).
Browsers disagree. A 200×100 PNG drawn with drawImage(img, 0, 0):
It'd be good to say explicitly which coordinate space the source rectangle and the default destination size use. createImageBitmap(img) gives a 200px-wide bitmap in Chrome Canary, Firefox Nightly, and Safari TP for both cases, so it uses image pixels; WebGL's texImage2D() probably needs the same answer.
Activity