w3c / ColorWeb-CG

repo for the Color on the Web Community Group
51 stars 21 forks source link

Do not change default return type for getImageData #105

Closed ccameron-chromium closed 1 year ago

chrisn commented 1 year ago

This change would leave the proposal without a way to get the image data for a float16 backed canvas. Is the idea to propose adding a getHDRImageData() or similar?

ccameron-chromium commented 1 year ago

This change would leave the proposal without a way to get the image data for a float16 backed canvas. Is the idea to propose adding a getHDRImageData() or similar?

No.

The function getImageData takes an ImageDataSettings parameter. In this proposal we have added colorType to ImageDataSettings.

The following code will always return sRGB float32 data, regardless of the color space or pixel format of the canvas itself.

  myData = context.getImageData(x, y, w, h, {colorSpace:"srgb", colorType:"float32"})
chrisn commented 1 year ago

I see, thanks!

palemieux commented 1 year ago

I think this PR is in line with https://github.com/w3c/ColorWeb-CG/blob/main/hdr_html_canvas_element.md#extend-imagedatasettings-to-support-higher-bit-depths where the default value for dataType is "unorm8".

@ccameron-chromium Can you confirm?

ccameron-chromium commented 1 year ago

I think this PR is in line with https://github.com/w3c/ColorWeb-CG/blob/main/hdr_html_canvas_element.md#extend-imagedatasettings-to-support-higher-bit-depths where the default value for dataType is "unorm8".

@ccameron-chromium Can you confirm?

Yes, that is correct, these result in the same behavior.

(There is a slight difference in that one defines how things behave when this is not specified, which could be because no ImageDataOptions is specified, or because the ImageDataOptions does not specify dataType).