ImageData Class
A rectangle of pixels (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagedata): its width, its height, and its pixels, row by row, 4 components per pixel (R, G, B, A, not premultiplied), as bytes or half-precision floats.
public sealed class ImageDataRemarks
The pixels are shared with the scripts: an ImageData created from a Uint8ClampedArray views its bytes, and the array returned by the data attribute to the scripts is the one the .NET code reads and writes (ImageData.Data).
See also
Constructors
| Name | Description |
|---|---|
| ImageData(object, uint, uint?, ImageDataSettings?) | Creates an image data viewing pixels (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata-with-data): the Uint8ClampedArray or Float16Array of a script, or bytes (an array or a Memory<T> of bytes, which are not copied). |
| ImageData(uint, uint, ImageDataSettings?) | Creates an image data of transparent black pixels (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata). |
ImageData overloads
ImageData(object, uint, uint?, ImageDataSettings?)
ImageData.csCreates an image data viewing pixels (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata-with-data): the Uint8ClampedArray or Float16Array of a script, or bytes (an array or a Memory<T> of bytes, which are not copied).
public ImageData(object data, uint sw, uint? sh = null, ImageDataSettings? settings = null)Parameters
dataobject- The pixels.
swuint- The width in pixels.
shuint?- The height in pixels, or null to compute it from the length of the data.
settingsImageDataSettings?- The color space and the format of the pixels (the format of the data).
Exceptions
DomException- An
InvalidStateErrorwhen the number of components is not a nonzero multiple of 4 or the format does not match the array, anIndexSizeErrorwhen the number of pixels is not a multiple of the width or does not match the height.
See also
ImageData(uint, uint, ImageDataSettings?)
ImageData.csCreates an image data of transparent black pixels (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata).
public ImageData(uint sw, uint sh, ImageDataSettings? settings = null)Parameters
swuint- The width in pixels.
shuint- The height in pixels.
settingsImageDataSettings?- The color space and the format of the pixels.
Exceptions
DomException- An
IndexSizeErrorwhen the width or the height is 0 or the pixels are too large.
See also
Properties
| Name | Description |
|---|---|
| ColorSpace | Gets the color space of the pixels. |
| Data | Gets the bytes of the pixels: 4 bytes per pixel (R, G, B, A) for ImageDataPixelFormat.RgbaUnorm8, 4 half-precision floats (Half, in the byte order of the platform) for ImageDataPixelFormat.RgbaFloat16. The bytes are shared with the array of the scripts; they are empty when its buffer is detached. |
| DataArray | Gets the array of the pixels for the scripts (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata-data): use ImageData.Data in .NET code. |
| Height | Gets the height in pixels. |
| PixelFormat | Gets the format of the pixels. |
| Width | Gets the width in pixels. |
ColorSpace
ImageData.csGets the color space of the pixels.
public PredefinedColorSpace ColorSpace { get; }Data
ImageData.csGets the bytes of the pixels: 4 bytes per pixel (R, G, B, A) for ImageDataPixelFormat.RgbaUnorm8, 4 half-precision floats (Half, in the byte order of the platform) for ImageDataPixelFormat.RgbaFloat16. The bytes are shared with the array of the scripts; they are empty when its buffer is detached.
Property value
DataArray
ImageData.csGets the array of the pixels for the scripts (https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-imagedata-data): use ImageData.Data in .NET code.
public object DataArray { get; }Height
ImageData.csGets the height in pixels.
public uint Height { get; }PixelFormat
ImageData.csGets the format of the pixels.
public ImageDataPixelFormat PixelFormat { get; }Width
ImageData.csGets the width in pixels.
public uint Width { get; }