Why does HTML Canvas getImageData() not return the exact same values that were just set?

ImageData is defined in HTML5 as being unpremultiplied, but most canvas implementations use a premultiplied backing buffer to speed up compositing, etc. This means that when data is written and then read from the backing buffer it can change.

I would assume that Chrome v8 picked up a buggy version of the [un]premultiplying code from webkit.org (It has been broken before, although i don’t recall any recent occurances, and that doesn’t explain the windows only variance)

[edit: it could be worth checking a webkit nightly on windows? as the imagedata implementation doesn’t have anything platform specific it’s shared between all webkit browsers and could simply be broken in MSVC based builds]

Leave a Comment