大网数据广告活动
Web 标准与前端开发

ImageData: pixelFormat property

· 52CE 我爱测

The read-only **`ImageData.pixelFormat`** property is a string indicating the pixel format of the image data.

Canvas API

The read-only ImageData.pixelFormat property is a string indicating the pixel format of the image data.

The pixel format can be set during ImageData initialization using either the ImageData() constructor or the createImageData() method.

Value

This property can have the following values:

  • "rgba-unorm8" representing RGBA with 8 bit per component unsigned normalized format, using a Uint8ClampedArray.
  • "rgba-float16" representing RGBA with 16 bits per component, using a Float16Array. Floating-point pixel values allow representing colors in arbitrarily wide gamuts and high dynamic range (HDR).

Examples

Floating-point pixel data for wide gamuts and high dynamic range (HDR)

Floating-point pixel values allow representing colors in arbitrarily wide gamuts and high dynamic range (HDR). You can set the pixelFormat setting to "rgba-float16" to use RGBA values with 16 bits per component. This requires the dataArray to be a Float16Array.

let floatArray = new Float16Array(4 * 200 * 200);
let imageData = new ImageData(floatArray, 200, 200, {
  pixelFormat: "rgba-float16",
});
console.log(imageData.pixelFormat); // "rgba-float16"

Specifications

Browser compatibility

See also

  • ImageData
  • Float16Array
  • CanvasRenderingContext2D.createImageData()
  • CanvasRenderingContext2D.putImageData()

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。