画布保存为图片,仿真时保存正常,真机调试时图片几乎全黑,这是为什么?
发布于 4 年前 作者 tao69 860 次浏览 来自 官方Issues

这是保存的图片,下边是调试时保存的,上边一个是真机调试,内容一样但保存不一样。下面是保存部分的代码。

that.data.ccp.draw(false, function () {

console.log("downImg ");

setTimeout(function () {

console.log("that.data.ccp.draw ");

let params = {

x: 0,

y: 0,

width: 265,

height: 130,

destWidth: 212,

destHeight: 104,

canvasId: ‘cardcanvas’,

fileType: ‘jpg’,

}

wxCanvasToTempFilePath(params).then(res => {

console.log("wxCanvasToTempFilePath ", JSON.stringify(res));

let params = {

tempFilePath: res.tempFilePath,

}

return wxSaveFile(params)

}).then(res => {

let temp_cardpath = res.savedFilePath

console.log("wxSaveFile ", JSON.stringify(res));

that.setData({

cardpath: temp_cardpath

})

}

哪位大神碰到过,走过路过的帮忙看看啦!谢谢各位

2 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

将图片保存到本地路径然后再去绘制, 不然容易出现canvas画不上图片,然后保存图片到本地时候出现保存失败的问题。可参考:https://blog.csdn.net/lmx15063393957/article/details/93734975

回到顶部