admin管理员组

文章数量:1321817

Needed to do some pixel manipulation, but ImageData has changed. Now it has a colorSpace property.

What is this, and how do I use it as normal?

Just get an ImageData object in Chrome to reproduce.

Needed to do some pixel manipulation, but ImageData has changed. Now it has a colorSpace property.

What is this, and how do I use it as normal?

Just get an ImageData object in Chrome to reproduce.

Share Improve this question edited May 25, 2022 at 13:38 Yves M. 31k24 gold badges109 silver badges149 bronze badges asked Apr 24, 2017 at 7:49 KrisoKriso 1651 gold badge2 silver badges10 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 10

This es from this proposal to implement color-space management in canvas.

Currently, canvas is stuck with legacy-srgb 8 bit depth. Some monitor can't handle this low level of information.

This is still a proposal, but the currently proposed syntax to set the colorSpace of a 2DContext would be ctx.getContext('2d', {colorSpace: 'color-space', pixelFormat: 'pixelFormat', linearPixelMath: boolean});

Currently, no one has implemented it yet, but chromium and chrome are in the process of doing so.
Their current implementation only exposes a getter colorSpace property on ImageData objects, and a getContextAttributes method on the Context2D object, but there is not yet a way to set it for us (maybe there is with some startup flag, but I didn't find it).

Note: You need to set the Experimental canvas features flag to true in chrome://flags to get access to these properties.

But anyway, this property should in no way alter your code. All the default parameters of the ImageData are still the same.

本文标签: javascriptWhat is quotcolorspacequot in imagedataStack Overflow