let that = this;
wx.chooseImage({
success: function (res) {
var tempFilePaths = res.tempFilePaths
console.log(tempFilePaths[0])
let canvas = wx.createCanvasContext('myCanvas')
canvas.drawImage(tempFilePaths[0], 0, 0, 75, 75)
canvas.draw()
wx.canvasGetImageData({
canvasId: 'myCanvas',
x: 0,
y: 0,
width: 75,
height: 75,
success (res) {
console.log(":res", res)
let pngData = upng.encode([res.tempFilePaths[0]], 75, 75)
let base64 = wx.arrayBufferToBase64(pngData)
console.log("=---", base64)
}
})
wx.setStorageSync('addImg', tempFilePaths[0])
that.setData({
addImg: tempFilePaths[0]
})
})
}
})
|