web api interface
ImageData
Available in workers
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().
Constructors
ImageData()- : Creates an
ImageDataobject from a givenUint8ClampedArrayorFloat16Arrayand 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.
- : Creates an
Instance properties
dataRead only- : A
Uint8ClampedArrayorFloat16Arrayrepresenting a one-dimensional array containing the data in the RGBA order. The order goes by rows from the top-left pixel to the bottom-right.
- : A
colorSpaceRead only- : A string indicating the color space of the image data.
heightRead only- : An
unsigned longrepresenting the actual height, in pixels, of theImageData.
- : An
widthRead only- : An
unsigned longrepresenting the actual width, in pixels, of theImageData.
- : An
pixelFormatRead only Experimental- : A string indicating the format to use for the
ImageData.
- : A string indicating the format to use for the
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
CanvasRenderingContext2D- The
<canvas>element and its associated interface,HTMLCanvasElement.