CanvasContext.putImageData

Draw the pixel data into the canvas.

Parameters

It is Object type.

PropertyType

Required

Description
dataUint8ClampedArrayYesImage pixel data, it is an array, and the four elements represent the rgba data.
xNumberYesThe x offset for the original data in the destination canvas.
yNumberYesThe y offset for the original data in the destination canvas.
widthNumberYesThe width of the original data.
heightNumberYesThe height of the original data.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Sample Code

copy
// .js
const data = new Uint8ClampedArray([255, 0, 0, 1])
const ctx = my.createCanvasContext('awesomeCanvas')

ctx.putImageData({
    x: 0,
    y: 0,
    width: 1,
    height: 1,
    data: data,
    success(res) {}
})