canvasPutImageData 无法绘制data
发布于 5 年前 作者 dzhao 6339 次浏览 来自 问答

canvasPutImageData在开发工具中可以在canvas上输出图片,但是真机无法输出。

尝试在putImageData前清空画布,回调函数中setTimeOut一段时间再绘制,依旧无法生成,请检查,谢谢。

wx.canvasGetImageData({

canvasId: ‘picEffect’,

x: 0,

y: 0,

width: that.data.picWidth,

height: that.data.picHeight,

success:function(res){

var data=res.data;

if (imgData.length > 0) {

data = imgData;

}

else {

imgData=res.data;

}

var result=new Uint8ClampedArray(res.data.length);

………………

}

var ctx = wx.createCanvasContext(‘picEffect’);

ctx.clearRect(0,0,that.data.picWidth,that.data.picHeight);

ctx.draw(true, setTimeout(function () {

wx.canvasPutImageData({

canvasId: ‘picEffect’,

data: result,

x: 0,

y: 0,

width: that.data.picWidth,

height: that.data.picHeight,

success: function (res) {

console.log(res);

wx.hideLoading();

},

fail: function (res) {

console.log(res);

}

})},100));

}

2 回复

,你好,测试是可以的哦

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部