WICG / canvas-color-space

Proposed web platform feature to add color management, wide gamut and high bit-depth support to the <canvas> element.
Other
81 stars 19 forks source link

support low-color mode such as RGB565? #21

Open klausw opened 7 years ago

klausw commented 7 years ago

I'm working on WebVR implementation on Android, and I think it would be useful if an application could opt in to a lower color depth canvas mode such as RGB565 if it doesn't need precise colors but wants to maximize performance. On some hardware, this could reduce the per-pixel storage from 32bit to 16bit and double effective memory throughput. Hardware where this mode is not supported efficiently would be free to ignore this and use RGB8888 instead.

I assume that this use case isn't very interesting to people who want precise color and HDR, but it sounds as if it would be a fairly natural fit to this proposed API as a canvas attribute.

What do people think? Would you be open to adding an optional "5-6-5-0" as a requested color format option?

zbjornson commented 7 years ago

If you or anyone else wants to try this mode out, it's supported in node-canvas 2.x (available as v2.0.0-alpha.5) (see https://github.com/Automattic/node-canvas/#image-pixel-formats-experimental). Doesn't help for WebVR but might help for other testing purposes.

canvas.getContext("2d", {pixelFormat: "RGB16_565"})

In this case, ImageData (as returned by getImageData or received by putImageData) is a Uint16Array.