W3C home > Mailing lists > Public > public-canvas-api@w3.org > July to September 2009

Canvas, color management and GetImageData

From: Frank Olivier <franko@microsoft.com>
Date: Wed, 16 Sep 2009 22:39:40 +0000
To: "public-canvas-api@w3.org" <public-canvas-api@w3.org>
Message-ID: <DBB7A800D05F0C44A5EBA0231C567C3918816438@TK5EX14MBXW652.wingroup.windeploy.ntdev.microsoft.com>
Section "Color spaces and color correction" imho contains confusing language.

>From the spec: [with my annotations]
>The canvas APIs must perform color correction at only two points:
>[ConversionA] when rendering images with their own gamma correction and color space information [call this image-space] onto the canvas, to convert the image to the color space used by the canvas [call this canvas-space]
>[ConversionB] and when rendering the actual canvas bitmap to the output device. [call this display-space]

>Note: Thus, in the 2D context, colors used to draw shapes onto the canvas will exactly match colors obtained through the getImageData() method.

[image-space] is defined in the image file.
[canvas-space] (from my reading of the spec) is not clearly defined.
[display-space] is set by the OS; Windows automatically sets up the correct display profiles for a large number of displays. The space differs from machine to machine.

Now, if the image doesn't contain any color profile information, it seems that the raw pixel color values from the file are painted into the canvas, and onto the screen (in Safari 4.0.3, Firefox 3.5; this imho is correct behavior, as you don't introduce color shifts for web developers who don't care about color management.)

In the case where image-space is defined, the spec indicates that color correction should only be done at two points - when moving pixels from image-space to canvas-space, and from canvas-space to display-space. (ConversionA, ConversionB) OK.
When I call getImageData() on the canvas (in Safari 4.0.3, Firefox 3.5), I get RGBA values in display-space (in other words, already converted to the display profile)

So, based on the language in the spec, and the 2 current implementations of color-managed canvas, it seems that:
canvas-space = display-space?

ConversionA converts from image-space to canvas-space (aka display-space)
ConversionB converts from canvas-space to display-space (but as they are the same, no color values are actually changed)

Is the intent of the spec that canvas-space = display-space?

Frank Olivier
Received on Thursday, 17 September 2009 07:40:42 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:31:48 UTC