canvasToImageBuffer Function

Create an ImageBuffer in the specified format with the same dimensions and contents as a canvas.

canvasToImageBuffer(canvas: HTMLCanvasElement, format: ImageBufferFormatImageBufferFormat.Rgba): ImageBuffer | undefined

@returns an ImageBuffer object containing the contents of the source canvas, or undefined if the conversion fails.

Parameter Type Description
canvas HTMLCanvasElement the source HTMLCanvasElement object from which the ImageBuffer object will be constructed.
format ImageBufferFormat the desired format of the created ImageBuffer; defaults to ImageBufferFormat.Rgba.

Returns - ImageBuffer | undefined

an ImageBuffer object containing the contents of the source canvas, or undefined if the conversion fails.

Defined in

Last Updated: 14 November, 2024