Investigate the correct behavior of color managed ImageData |
|||
Issue descriptionAccording to https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md#imagedata, the expected behavior of color managed ImageData is as follows: * ImageData imagedata = ctx.getImageData(sx, sy, sw, sh); * ImageData imagedate = ctx.createImageData(width, height); No color conversion. imagedata follows the color settings of the canvas. * void ctx.putImageData(imagedata, dx, dy, ...); * ImageData imagedata = ctx.createImageData(imagedata); Color conversion, if needed, to the color settings of the canvas. *ImageData ctx.createImageData(width, height, imageDataColorSettings); No color conversion to the color settings of the canvas. ImageData will be created based on imageDataColorSettings. *ImageData ctx.createImageData(data, width, height, imageDataColorSettings); Color conversion, if needed, from the color settings of the canvas to imageDataColorSettings. Currently, Chrome supports the following combinations of color space and pixel format: * Legacy and SRGB, Uint8 * LinearRGB and P3 and Rec2020, Float16 However, for ImageDataColorSettings, both Uint8 and Float32 (not supportig Uint16 for now) can be used with a SRGB, linear RGB, P3 or Rec2020 color space. * Uint8+SRGB and Float32+{linearRGB,P3,Rec2020} is straightforward. * Uint8+{linearRGB,P3,Rec2020} requires storage format conversion to float16 (or float32->float16) when put to a float16-backed canvas. floatVal = uintVal / 255.0. * Float32+SRGB requires storage format conversion and clamping when put to a canvas (with any color space). uintVal = std::max(0, std::min(255, std::floor(floatVal * 255))). We should first verify that the above behavior is correct. Next, we need to provide enough layout test coverage. Some tests are already present in third_party/WebKit/LayoutTests/virtual/color_space/fast/canvas/color-space/.
,
Aug 29 2017
This looks right to me. One minor thing color correction is a non-issue for ctx.createImageData(width, height) and ctx.createImageData(width, height, imageDataColorSettings), since these overloads create blank ImageData.
,
Aug 29 2017
But they need to set the buffer size according to the color space, right?
,
Sep 7 2017
Correction for the last item: *ImageData ctx.createImageData(data, width, height, imageDataColorSettings); No color conversion to the color settings of the canvas. ImageData is created from param "data" with proper storage format and is tagged with the CanvasColorSpace which is given in imageDataColorSettings. Also as of now we are supporting all the possible operations (create, get, put) on ImageData with "uint16" storage format.
,
Sep 11 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9e86ad8d35b56a7d4cd4ed22e0dfa5a4bca574e3 commit 9e86ad8d35b56a7d4cd4ed22e0dfa5a4bca574e3 Author: Reza.Zakerinasab <zakerinasab@chromium.org> Date: Mon Sep 11 17:22:11 2017 Add layout test to verify correct behavior of color managed ImageData API This change adds a layout test that passes all the possible combinations of parameters to color managed ImageData API and examines the result. More discussion can be found in the bug page. Bug: 758669 Change-Id: Icd22a49f51177b8238ec9702128f3e30e5c8287c Reviewed-on: https://chromium-review.googlesource.com/655622 Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org> Reviewed-by: Justin Novosad <junov@chromium.org> Cr-Commit-Position: refs/heads/master@{#500947} [add] https://crrev.com/9e86ad8d35b56a7d4cd4ed22e0dfa5a4bca574e3/third_party/WebKit/LayoutTests/virtual/color_space/fast/canvas/color-space/imageData-colorManagedBehavior.html
,
Sep 11 2017
,
Nov 27 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by zakerinasab@chromium.org
, Aug 24 2017