v160 · graphics · canvas

Encode & ImageBitmap round-trip

The edge most apps hit first: you paint HDR, then save it. The explainer says a "standard" canvas encodes for maximum SDR precision (values clamp to white), while an "extended" canvas encodes with an HDR transfer function (HLG for 8-bit, PQ for deeper) so the highlights survive the file. This page reruns the exact WPT round-trip — paint 16× SDR white, encode, decode into a fresh float16 canvas, read the pixel back — for every export path.

Shipping status & how to enable. Chrome 160 is planned to ship this enabled for everyone. Until then it sits behind the Blink runtime feature CanvasToneMapping (status experimental in runtime_enabled_features.json5). To run it today in Chrome or Canary: turn on chrome://flags/#enable-experimental-web-platform-features (there is no dedicated chrome://flags entry), or launch with --enable-blink-features=CanvasToneMapping. Seeing brighter-than-white pixels additionally needs an HDR-capable display and OS HDR mode — this page reports (dynamic-range: high) so you know which case you are in.

Probing this browser…

Run the round-trip matrix

Choose a format and run.
Red channel read back from a float16 destination canvas. Expected values follow html/canvas/…/wide-gamut-canvas/encode-hdr.html.
export pathmodeexpectedmeasuredresult
not run yet

the round-trip, verbatim

const src = new OffscreenCanvas(16, 16).getContext("2d", {
  colorSpace: "srgb-linear", colorType: "float16",
  toneMapping: { mode },               // "standard" | "extended"
});
src.fillStyle = "color(srgb-linear 16 16 16)";
src.fillRect(0, 0, 16, 16);
const blob = await src.canvas.convertToBlob({ type: "image/png" });

const img = await createImageBitmap(blob);
const dst = new OffscreenCanvas(16, 16).getContext("2d",
  { colorSpace: "srgb-linear", colorType: "float16" });
dst.drawImage(img, 0, 0);
dst.getImageData(8, 8, 1, 1, { pixelFormat: "rgba-float16" }).data[0];
// standard → ≈1  (clamped to SDR white for maximum SDR precision)
// extended → ≈16 (HDR transfer function kept the highlight)

The ImageBitmap rows (createImageBitmap(canvas), transferToImageBitmap()) are informational: the explainer requires the bitmap to carry the canvas’s tone-mapping state, and explicit bitmap state tracking is still open in whatwg/html#13235, so there is no pinned number to compare against yet. If srgb-linear is unavailable the page uses srgb at 2.0 instead and says so — an approximation of the WPT, not the WPT itself.

see also