用不同手机测试微信小游戏截图功能时,所截得的图片内容显示不一样?
发布于 6 年前 作者 xiuying41 11637 次浏览 来自 问答

用 canvas.toTempFilePath() 截得的图,游戏制作是按iPhone5S的屏幕尺寸640*1136来制作的,在不同的手机上的内容不一样,第一张是在iPhone6 plus,只显示了一块; 第二张是在iPhone5S上,能正确显示 ,请问下是什么原因,这个问题要怎么解决?

4 回复

你的 x,y,width,height 都乘以 当前手机的 dpr 值,这样所有的手机就都正常了!

例如:

let dpr = window.devicePixelRatio;

       let x = _this._x;

       let y = (_this.processHeight + 10) * dpr;

       let w = sw * dpr;

       let h = (_this.equallHeight * 9) * dpr;

       canvas.toTempFilePath({

         x: x,

         y: y,

         width: w,

         height: h,

         destWidth: w,

         destHeight: w*0.8,

         success: (res) => {

           wx.shareAppMessage({

             imageUrl: res.tempFilePath

           })

         }

       })

请问最后怎么解决的?

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

ios版本是8.4.1

回到顶部