ImageData

ImageData interface represents the underlying pixel data of an area of a <canvas> element. It is created using the ImageData() constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: createImageData() and getImageData() . It can also be used to set a part of the canvas by using putImageData() .

构造函数

ImageData()
创建 ImageData object from a given Uint8ClampedArray and the size of the image it contains. If no array is given, it creates an image of a transparent black rectangle. Note that this is the most common way to create such an object in workers as createImageData() is not available there.

特性

ImageData.data 只读
Uint8ClampedArray representing a one-dimensional array containing the data in the RGBA order, with integer values between 0 and 255 (inclusive).
ImageData.height 只读
Is an unsigned long representing the actual height, in pixels, of the ImageData .
ImageData.width 只读
Is an unsigned long representing the actual width, in pixels, of the ImageData .

规范

规范 状态 Comment
HTML Living Standard
The definition of 'ImageData' in that specification.
实时标准

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
ImageData Chrome 4 Edge 12 Firefox 14 IE 9 Opera 9 Safari 3.1 WebView Android ≤37 Chrome Android 18 Firefox Android 14 Opera Android 10.1 Safari iOS 3.2 Samsung Internet Android 1.0
ImageData() 构造函数
Chrome 42 Edge ≤18 Firefox 29 IE 不支持 No Opera 29 Safari ? WebView Android 不支持 No Chrome Android 42 Firefox Android 29 Opera Android ? Safari iOS ? Samsung Internet Android 4.0
data Chrome Yes Edge 12 Firefox 14 IE 9 Opera 9 Safari 3.1 WebView Android Yes Chrome Android Yes Firefox Android 14 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
height Chrome Yes Edge 12 Firefox 14 IE 9 Opera 9 Safari 3.1 WebView Android Yes Chrome Android Yes Firefox Android 14 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
width Chrome Yes Edge 12 Firefox 14 IE 9 Opera 9 Safari 3.1 WebView Android Yes Chrome Android Yes Firefox Android 14 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
Available in workers Chrome Yes Edge ≤79 Firefox 25 IE ? Opera ? Safari ? WebView Android Yes Chrome Android Yes Firefox Android 25 Opera Android ? Safari iOS ? Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。

另请参阅