wx.getImageInfo({
src: uri,
success(res) {
console.log(res)
const canvas = wx.createOffscreenCanvas({ type: '2d', width: data.data?.w, height: data.data?.h })
const id = canvas.id
const context = canvas.getContext('2d')
context.clearRect(0, 0, data.data?.w, data.data?.h)
const image = canvas.createImage()
image.src = res.path
image.onload = () => {
console.log(canvas)
console.log(21)
context.drawImage(image, data.data?.x, data.data?.y, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height)
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: canvas.width,
height: canvas.height,
canvas: canvas,
canvasId: id,
success(res) {
console.log("res.tempFilePath = " + res.tempFilePath)
if (res.tempFilePath) {
callback && callback({
code: 0,
data: {
uri: res.tempFilePath,
width: canvas.width,
height: canvas.height
}
});
} else {
callback && callback({
code: 405,
msg: '照片处理失败,请重新选择或拍照!'
});
}
},
fail(err) {
console.log('fail', err);
callback && callback({
code: 405,
msg: '照片处理失败,请重新选择或拍照!'
});
}
})
}
},
fail(err) {
console.log('fail', err);
callback && callback({
code: 405,
msg: '照片处理失败,请重新选择或拍照!'
});
}
});
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
同问,请问有谁解决了这个问题?
请问解决了吗