In the WeChat applet API, drawImage is used to draw the image, and the image maintains its original size.


drawImage


Definition

Draws an image, keeping the original size of the image.

Parameters

QQ截图20170208145724.png

Example

const ctx = wx.createCanvasContext('myCanvas')

wx.chooseImage({
  success: function(res){
    ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100)
    ctx.draw()
  }
})

201612261752293491.png