canvasToImageBuffer Function

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

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

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 Rgba.

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

Defined in

Last Updated: 20 September, 2019