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
ImageData
object from a givenUint8ClampedArray
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 ascreateImageData()
is not available there.
Properties
-
ImageData.data
Read only -
Is a
Uint8ClampedArray
representing a one-dimensional array containing the data in the RGBA order, with integer values between0
and255
(inclusive). -
ImageData.height
Read only -
Is an
unsigned long
representing the actual height, in pixels, of theImageData
. -
ImageData.width
Read only -
Is an
unsigned long
representing the actual width, in pixels, of theImageData
.
Specifications
Specification |
---|
HTML Standard (HTML) # imagedata |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
ImageData |
1 |
12 |
14 |
9 |
9 |
3.1 |
≤37 |
18 |
14 |
10.1 |
2 |
1.0 |
ImageData |
42 |
14 |
29 |
No |
29 |
7 |
No |
42 |
29 |
? |
7 |
4.0 |
data |
1 |
12 |
14 |
9 |
9 |
3.1 |
≤37 |
18 |
14 |
10.1 |
2 |
1.0 |
height |
1 |
12 |
14 |
9 |
9 |
3.1 |
≤37 |
18 |
14 |
10.1 |
2 |
1.0 |
width |
1 |
12 |
14 |
9 |
9 |
3.1 |
≤37 |
18 |
14 |
10.1 |
2 |
1.0 |
worker_support |
Yes |
≤79 |
25 |
? |
? |
7 |
Yes |
Yes |
25 |
? |
7 |
Yes |
See also
CanvasRenderingContext2D
- The
<canvas>
element and its associated interface,HTMLCanvasElement
.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ImageData