CanvasContext.putImageData

Draw the pixel data into the canvas.

Parameters

It is Object type.

FieldTypeMandatoryDescription
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
successFunctionNoThe success callback function
failFunctionNoThe fail callback function
completeFunctionNoThe complete callback function

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) {}
})