ImageData
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().
Note: This feature is available in Web Workers
Constructors
ImageData()-
Creates an
ImageDataobject from a givenUint8ClampedArrayand 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 ascreateImageData()is not available there.
Properties
ImageData.dataRead only-
Is a
Uint8ClampedArrayrepresenting a one-dimensional array containing the data in the RGBA order, with integer values between0and255(inclusive). ImageData.heightRead only-
Is an
unsigned longrepresenting the actual height, in pixels, of theImageData. ImageData.widthRead only-
Is an
unsigned longrepresenting the actual width, in pixels, of theImageData.
Specifications
| Specification |
|---|
| HTML Standard # imagedata |
Browser compatibility
BCD tables only load in the browser
See also
CanvasRenderingContext2D- The
<canvas>element and its associated interface,HTMLCanvasElement.