Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not change default return type for getImageData #105

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

ccameron-chromium
Copy link
Collaborator

No description provided.

@chrisn
Copy link
Member

chrisn commented Jul 25, 2023

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
Copy link
Collaborator Author

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
Copy link
Member

chrisn commented Jul 25, 2023

I see, thanks!

@palemieux
Copy link
Contributor

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?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 28, 2023
Allow users to create 2d context with pixelFormat float16, i.e., users
can now create context like: ctx = canvas.getContext('2d',
{pixelFormat: 'float16'}).

Note that the default colortype for getImageData is uint8, so calls like
`ctx.getImageData(x, y, w, h)` without `colortype` returns pixels in
format uint8 with context of type float16.

proposal:
w3c/ColorWeb-CG#105

Bug: 1468666

Change-Id: I0309c6d8c573edc84a6a6643ea8ae9563986a242
@ccameron-chromium
Copy link
Collaborator Author

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

@ccameron-chromium ccameron-chromium merged commit dad50b2 into w3c:main Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants