# wx.canvasPutImageData(Object object, Object this)

Start from base library version 1.9.0. Please remaining backward compatible.

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 1.9.6

Draws pixel data to the canvas. Under custom components, the second parameter passes in the custom component instance This to operate within the component &ltcanvas&gt assembly

# parameter

# Object object

attribute type Default values Required Introductions
canvasId string yes Canvas identity, passed in canvas Component canvas-id Property.
data Uint8ClampedArray yes Image pixel data, one-dimensional array, every four items representing a pixel rgba
x number yes Position offset of source image data in the target canvas x Offset in the axial direction)
and number yes The position offset of the source image data in the target canvas (y Offset in the axial direction)
width number yes Width of the rectangular region of source image data
height number yes Height of rectangular region of source image data
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Interface calls the end of the callback function (call success or failure will be executed)

# Object this

Under a custom component, the this of the current component instance to manipulate within the component canvas assembly

# sample code


const data = new Uint8ClampedArray([255, 0, 0, 1])
wx.canvasPutImageData({
  canvasId: 'myCanvas',
  x: 0,
  and: 0,
  width: 1,
  height: 1,
  data: data,
  success (res) {}
})