问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本 API和组件 小程序 Bug canvasContext.drawImage 工具 6.6.5 1.9.98 canvasContext.drawImage大图压缩成小图图片失真怎么解决代码片段Page({ data: { }, onLoad: function () { var that = this; var _winwidth = 0; var _winheight = 0; wx.getSystemInfo({ success: function (res) { _winwidth = res.windowWidth; _winheight = res.windowHeight; that.setData({ shareCanvasWidth: _winwidth, shareCanvasheight: _winheight, src: '../images/bj1.png' }) const ctx = wx.createCanvasContext('shareCanvas') console.log(ctx); ctx.drawImage('../images/bj1.png', 0, 0, _winwidth, _winheight) ctx.drawImage('../images/sp.jpg', 104 / 2588 * _winwidth, 2061 / 4600 * _winheight, 2369 / 2588 * _winwidth, 1357 / 4600 * _winheight) ctx.drawImage('../images/erw.jpg', 1773 / 2588 * _winwidth, 3862 / 4600 * _winheight, 600 / 2588 * _winwidth, 600 / 4600 * _winheight) ctx.stroke() ctx.draw() //将生成好的图片保存到本地,需要延迟一会,绘制期间耗时 wx.showToast({ title: '分享图片生成中...', icon: 'loading', duration: 500 }); setTimeout(function () { wx.canvasToTempFilePath({ x: 0, y: 0, width: _winwidth, height: _winheight, destWidth: _winwidth, destHeight: _winheight, canvasId: 'shareCanvas', success: function (res) { var tempFilePath = res.tempFilePath; that.setData({ imagePath: tempFilePath, maskHidden: false // canvasHidden:true }); wx.hideToast() // wx.saveImageToPhotosAlbum({ // filePath: res.tempFilePath, // success(res) { // wx.showToast({ // title: '已保存到相册' // }) // } // }) }, fail: function (res) { console.log(res); } }); }, 1000); } }) } })