CanvasContext.putImageData
Draw the pixel data into the canvas.
Parameters
It is Object type.
Property | Type | Required | Description |
data | Uint8ClampedArray | Yes | Image pixel data, it is an array, and the four elements represent the rgba data. |
x | Number | Yes | The x offset for the original data in the destination canvas. |
y | Number | Yes | The y offset for the original data in the destination canvas. |
width | Number | Yes | The width of the original data. |
height | Number | Yes | The height of the original data. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback 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) {}
})