The 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 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
Read only
Uint8ClampedArray
representing a one-dimensional array containing the data in the RGBA order, with integer values between 0
and 255
(included).ImageData.height
Read only
unsigned
long
representing the actual height, in pixels, of the ImageData
.ImageData.width
Read only
unsigned
long
representing the actual width, in pixels, of the ImageData
.Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'ImageData' in that specification. | Living Standard |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 4.0 | (Yes) | 14 (14) | 9.0 | 9.0 | 3.1 |
Support in workers | (Yes) | ? | 25 (25) | ? | ? | ? |
ImageData() constructor | 43 | ? | 29 (29) | No support | 30 | ? |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | 2.1 | (Yes) | (Yes) | 14.0 (14) | ? | 10.0 | 3.2 | (Yes) |
Support in workers | ? | (Yes) | ? | 25.0 (25) | ? | ? | ? | (Yes) |
ImageData() constructor | ? | (Yes) | ? | 29.0 (29) | ? | ? | ? | (Yes) |
CanvasRenderingContext2D
<canvas>
element and its associated interface, HTMLCanvasElement
.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ImageData