Table of Contents

Class ImageData

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The ImageData interface represents the underlying pixel data of an area of a canvas element.

[Value("ImageData")]
public class ImageData
Inheritance
ImageData
Inherited Members

Remarks

It is created using the ImageData(ulong, ulong, ImageDataSettings) constructor or creator methods on the CanvasRenderingContext2D object associated with a canvas: CanvasRenderingContext2D.CreateImageData and CanvasRenderingContext2D.GetImageData. It can also be used to set a part of the canvas by using CanvasRenderingContext2D.PutImageData.

-CanvasRenderingContext2D
-The {{HTMLElement("canvas")}} element and its associated interface, HTMLCanvasElement.

See also on MDN

Constructors

ImageData()

public ImageData()

ImageData(Uint8ClampedArray, ulong, ulong, ImageDataSettings)

The ImageData() constructor returns a newly instantiated
'ImageData' object built from the typed array given and having the
specified width and height.

public ImageData(Uint8ClampedArray data, ulong sw, ulong sh = 0, ImageDataSettings settings = null)

Parameters

data Uint8ClampedArray
sw ulong
sh ulong
settings ImageDataSettings

Remarks

This constructor is the preferred way of creating such an object in a
'Worker'.

-CanvasRenderingContext2D.CreateImageData, the creator method that
can be used outside workers.

See also on MDN

ImageData(ulong, ulong, ImageDataSettings)

The ImageData() constructor returns a newly instantiated
'ImageData' object built from the typed array given and having the
specified width and height.

public ImageData(ulong sw, ulong sh, ImageDataSettings settings = null)

Parameters

sw ulong
sh ulong
settings ImageDataSettings

Remarks

This constructor is the preferred way of creating such an object in a
'Worker'.

-CanvasRenderingContext2D.CreateImageData, the creator method that
can be used outside workers.

See also on MDN

Properties

ColorSpace

The read-only ImageData.colorSpace property is a string indicating the color space of the image data.

[Value("colorSpace")]
public PredefinedColorSpace ColorSpace { get; }

Property Value

PredefinedColorSpace

This property can have the following values:

Remarks

Data

The readonly ImageData.data property returns a
{{jsxref("Uint8ClampedArray")}} or {{jsxref("Float16Array")}} that contains the ImageData object's
pixel data. Data is stored as a one-dimensional array in the RGBA order.

[Value("data")]
public Uint8ClampedArray Data { get; }

Property Value

Uint8ClampedArray

The type depends on the ImageData.PixelFormat used:

Remarks

-Height
-Width
-ImageData
-CanvasRenderingContext2D.CreateImageData
-CanvasRenderingContext2D.PutImageData
-Pixel manipulation with canvas

See also on MDN

Height

The readonly ImageData.height property returns the number
of rows in the ImageData object.

[Value("height")]
public ulong Height { get; }

Property Value

ulong

A number.

Remarks

Width

The readonly ImageData.width property returns the number
of pixels per row in the ImageData object.

[Value("width")]
public ulong Width { get; }

Property Value

ulong

A number.

Remarks