解决了么,我这destWidth基于比例放大也没用
借助canvas生成的图片模糊不清- 调用此接口通过canvas生成保存到手机相册的图片不如以前的清晰 - js代码 [代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]var[代码] [代码]ctx = wx.createCanvasContext([代码][代码]"canvas"[代码][代码], [代码][代码]this[代码][代码])[代码][代码] [代码][代码]wx.chooseImage({[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]var[代码] [代码]path = res.tempFilePaths[[代码][代码]0[代码][代码]][代码][代码] [代码][代码]ctx.drawImage(path, [代码][代码]0[代码][代码], [代码][代码]0[代码][代码], [代码][代码]375[代码][代码], [代码][代码]667[代码][代码])[代码][代码] [代码][代码]ctx.draw([代码][代码]true[代码][代码], [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]canvasId: [代码][代码]'canvas'[代码][代码],[代码][代码] [代码][代码]width:[代码][代码]375[代码][代码],[代码][代码] [代码][代码]height:[代码][代码]667[代码][代码],[代码][代码] [代码][代码]destWidth: [代码][代码]375[代码][代码]*[代码][代码]4[代码][代码],[代码][代码] [代码][代码]destHeight: [代码][代码]667[代码][代码]*[代码][代码]4[代码][代码],[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res.tempFilePath)[代码][代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码][代码] [代码][代码]filePath: res.tempFilePath,[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'保存成功'[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]wx.vibrateLong({})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码] -wxml代码 [代码]<[代码][代码]canvas[代码] [代码]style[代码][代码]=[代码][代码]'width:375px;height:667px;'[代码] [代码]canvas-id[代码][代码]=[代码][代码]"canvas"[代码][代码]></[代码][代码]canvas[代码][代码]>[代码] 图片可能在电脑上区别不明显,但是在手机上一眼就能看出来 -原图: [图片] -生成的图片 [图片]
2019-06-03