如何解决保存下来的海报图,小程序码(透明底)是黑色的?
发布于 7 年前 作者 yili 9399 次浏览 来自 官方Issues
const ctx = uni.createCanvasContext('myCanvas');
ctx.clearRect(0,0,that.canvasWidth,that.canvasHeight)
// 绘制海报
ctx.drawImage(posterinfo.path, 0, 0, posterinfo.width, posterinfo.height);
ctx.save();
// 绘制二维码
var codeWidth = 150;
var codeHeight = 150;
var codeX = that.canvasWidth - 25 - codeWidth; //二维码x坐标
var codeY = 25; //二维码y坐标
var arcR = codeWidth / 2;
ctx.beginPath();
ctx.arc(codeX + arcR, codeY + arcR, arcR, 0, 2 * Math.PI);
ctx.setFillStyle('rgba(255,255,255,0.6)');
ctx.fill();
ctx.drawImage(codeinfo.path, codeX, codeY, codeWidth, codeHeight);

回到顶部