收藏
回答

canvas.toTempFilePath截图保存图片,图片有严重的残影

框架类型 问题类型 操作系统 操作系统版本 手机型号 微信版本
小游戏 Bug Android 7.0 诺基亚6 6.6.7

小游戏渲染模式为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);

                        }

                    })

                }

            })


回答关注问题邀请回答
收藏

3 个回答

  • Special
    Special
    2018-06-15

    你们有线上的小游戏可以复现吗,复现步骤是?

    2018-06-15
    有用
    回复 7
    查看更多(2)
  • 我家有拖拉机🚜
    我家有拖拉机🚜
    2018-06-13

    这是正常效果:


    我的工程里有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);
                            }
                        })
                    }
                })
            }
        },


    2018-06-13
    有用
    回复
  • 疯狂的小辣椒
    疯狂的小辣椒
    2018-06-13

    麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

    也提供下截图正常和截图残影的对比照

    2018-06-13
    有用
    回复 1
    • 我家有拖拉机🚜
      我家有拖拉机🚜
      2018-06-15

      toTempFilePath 的 fileType 设置为'jpg'时, 没有问题。默认“png”时会出现上述情况。

      2018-06-15
      回复
登录 后发表内容