Re: [whatwg] WebGL and ImageBitmaps

On Fri, 16 May 2014, Justin Novosad wrote:
> 
> This is a longstanding issue with 2D canvas that several developers have
> complained about over the years.  The color space of the canvas backing
> store is currently unspecified.

It's defined that the colour space must be the same as used for CSS and 
<img>, but yeah the final colour space is left up to the UA:

   http://whatwg.org/html#color-spaces-and-color-correction


> Blink/WebKit uses output-referred color space, which is bad for some 
> inter-op cases, but good for performance. Calling drawImage will produce 
> inter-operable behavior as far as visual output is concerned, but 
> getImageData will yield values that have the display color profile baked 
> in.

I'm not quite sure what you mean here. If you mean that you can set 
'fillStyle' to a colour, fillRect the canvas, and the get the data for 
that pixel and find that it's a different colour, then that's 
non-conforming. If you mean that you can take a bitmap image without 
colour-profile information and draw it on a canvas and then getImageData() 
will return different results, then again, that's non-conforming.

If you mean that drawing an image with a color profile will result in 
getImageData() returning different colour pixels on different systems, 
then that's allowed, because the colour space of the canvas (and the rest 
of the Web platform, which must be the same colour space) is not defined.


> Some web developers have worked around this by reverse-engineering the 
> client-specific canvas to sRGB colorspace transform by running a test 
> pattern through drawImage+getImageData.  It is horrible that we are 
> making devs resort to this.

I'm not really sure what this work around achieves. Can you elaborate?

If you just want to do everything in sRGB, then putting all your images in 
sRGB but without giving color space information (or setting the option to 
'strip', if we add these createImageBitmap() options) would result in what 
you want, no?

You'd have to manually (or on the server) convert images that were in 
other colour spaces, though.


> Adding a colorspace option to createImageBitmap is not enough IMHO. I 
> think we need a more global color-management approach for canvas.

If we need colour management, we need it for the Web as a whole, not just 
for canvas. So far, though, implementations have not been implementing the 
features that have been proposed, so...:

   http://www.w3.org/TR/css3-color/#dropped

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 16 May 2014 16:29:34 UTC