W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2014

Re: [whatwg] WebGL and ImageBitmaps

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 16 May 2014 16:27:36 +0000 (UTC)
To: Justin Novosad <junov@google.com>
Message-ID: <alpine.DEB.2.00.1405161609580.27549@ps20323.dreamhostps.com>
Cc: Katelyn Gadd <kg@luminance.org>, "whatwg@whatwg.org" <whatwg@whatwg.org>, Glenn Maynard <glenn@zewt.org>, Rik Cabanier <cabanier@gmail.com>
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:


> 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...:


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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:20 UTC