这是正常效果: [图片] 我的工程里有cocos2d-js引擎,代码片段也超过200K,提交不了片段。 这是核心代码: [代码]saveShotToAlbum:[代码][代码]function[代码][代码](){[代码] [代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.getSetting({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]if[代码] [代码](!res.authSetting[[代码][代码]'scope.writePhotosAlbum'[代码][代码]]) {[代码][代码] [代码][代码]wx.authorize({[代码][代码] [代码][代码]scope: [代码][代码]'scope.writePhotosAlbum'[代码][代码],[代码][代码] [代码][代码]success() {[代码][代码] [代码][代码]shotAndSaveImage();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]shotAndSaveImage();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]function[代码] [代码]shotAndSaveImage(){[代码][代码] [代码][代码]var[代码] [代码]canvas = cc.game.canvas;[代码][代码] [代码][代码]var[代码] [代码]height = canvas.height;[代码][代码] [代码][代码]var[代码] [代码]width = canvas.width;[代码] [代码] [代码][代码]canvas.toTempFilePath({[代码][代码] [代码][代码]x: 0,[代码][代码] [代码][代码]y: 0,[代码][代码] [代码][代码]width: width,[代码][代码] [代码][代码]height: height,[代码][代码] [代码][代码]destWidth: width,[代码][代码] [代码][代码]destHeight: height,[代码][代码] [代码][代码]success (res) {[代码][代码] [代码][代码]console.log(res);[代码] [代码] [代码][代码]wx.saveImageToPhotosAlbum({[代码][代码] [代码][代码]filePath: res.tempFilePath,[代码][代码] [代码][代码]success:[代码][代码]function[代码][代码](r){[代码][代码] [代码][代码]console.log(r);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail:[代码][代码]function[代码][代码](r){[代码][代码] [代码][代码]console.log(r);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码]
canvas.toTempFilePath截图保存图片,图片有严重的残影小游戏渲染模式为Webgl时,canvas.toTempFilePath截图保存图片后,图片有严重的边缘残影。渲染模式为canvas时,没有这个问题。 在小游戏里是正常的,显示没有任何问题。 [图片] 代码: var canvas = cc.game.canvas; var height = canvas.height; var width = canvas.width; canvas.toTempFilePath({ x: 0, y: 0, width: width, height: height, destWidth: width, destHeight: height, success (res) { console.log(res); wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success:function(r){ console.log(r); cc.instantiate(that.tipsPrefab).getComponent('Tips').init(that.node, '保存成功', 0, 0, 500); }, fail:function(r){ console.log(r); } }) } })
2018-06-13mark,同样遇到这个问题。 wx.getFileSystemManager().getFileInfo()也读取不到这个临时文件。 啥时候能解决啊,在线等,急~
最新版 canvas.draw 无法绘制本地临时图片[代码]wx.downloadFile({[代码][代码] [代码][代码]url: imgUrl, // 一个网络图片[代码] [代码] success ({ tempFilePath }) {[代码] [代码] // 将临时图片地址绘制到画布上[代码] [代码] ctx.drawImage(tempFilePath, 0, 0, 100, 100)[代码] [代码] ctx.draw([代码][代码]false[代码][代码], () => {[代码][代码] // 这个回调一直没执行,控制台没有任何抛错[代码][代码] debugger[代码][代码] })[代码][代码] } [代码] [代码]})[代码]
2018-05-30遇到同样的问题,顶!
小游戏 截图临时路径无法保存本地canvas.toTempFilePath({ x: 0, y: 0, width: width, height: height, destWidth: width, destHeight: height, success(res){ console.log(res.tempFilePath); FileSystemManager.saveFile({ tempFilePath: res.tempFilePath, success(res) { console.log(res) }, fail(error) { console.log(error) } }) } })[图片] 临时路径是315c6e44-dc0e-4ee0-ad78-23b476744392,这个东西不知道是什么?但是能够预览图片却不能保存本地。网上看是http:或者是wxfile开头的~ 求大神帮忙~如何将截图的图片保存到本地~最好不好通过后台上传~
2018-05-30