微信小程序点击生成卡片分享,保存的图片都不是全屏的?

<canvas class='my' canvas-id='myCanvas' style='width:375px;height:667px'>
</canvas>

这是画图的代码

var abc = './3762-73772.jpg', def = 'tu27726_2.jpg'
var ctx = wx.createCanvasContext('myCanvas')

// ctx.drawImage(imgPath, 0 , 0 ,600,520)
ctx.setFillStyle('white')
ctx.fillRect(0,520,600,280)
ctx.drawImage(abc, (this.data.oscreenWidth - 280) / 2, (this.data.oscreenHeight - 480) / 2, 280, 380)
ctx.drawImage(def, 220, 320, 60, 60)
// ctx.draw()
ctx.drawImage(bgImgPath, 30, 520, 80, 100)
ctx.setGlobalAlpha(0.2)

ctx.setFillStyle('#6f6f6f')

ctx.font = "18px Arial";
ctx.fillText('歪歪歪', 110, 580)
ctx.draw()
setTimeout(() => {
  that.canvasImg()  这是调用的下面的图片生成
}, 700)
oscreenWidth获取的屏幕宽高,图片生成

wx.canvasToTempFilePath({

 canvasId: 'myCanvas', 
 x: 0,
 y: 0,
 width: this.data.oscreenWidth*2,
 height: this.data.oscreenHeight*2,
 destWidth: this.data.oscreenWidth * 3,
 destHeight: this.data.oscreenHeight * 3,
 success: function (res) {
   wx.hideLoading()
   console.log(res.tempFilePath, 'canvas画图片呀')
  
 }

})

这是原图

clipboard.png

这是手机保存到手机系统的图,保存手机不是全屏怎么回事
图片描述
阅读 4.1k
1 个回答
  1. 图片没有占满画布
  2. 图片/画布太小
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题