小游戏渲染模式为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);
}
})
}
})
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题
也提供下截图正常和截图残影的对比照
这是正常效果:
我的工程里有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); } }) } }) } }, |