<!--index.wxml--> <view class= "page" > <camera device-position= "back" flash= "off" binderror= "error" frame-size= "large" class= "mycamera" > </camera> <canvas canvas-id= "mycanvas" class= "mycanvas" > </canvas> </view> /**index.wxss**/ page{ width: 100%; height: 100%; } .mycamera{ top:0px; width: 100%; height: 50%; position: fixed; } .mycanvas{ top:50%; width: 100%; height: 100%; background-color: black; position: fixed; } //index.js //获取应用实例 const app = getApp() var nCounter = 0 var listener Page({ data: { }, onLoad: function () { }, onReady: function (res) { var that = this var camera_ctx = wx.createCameraContext() listener = camera_ctx.onCameraFrame((frame) => { if (nCounter == 0) { wx.canvasPutImageData({ canvasId: 'mycanvas' , x: 0, y: 0, width: frame.width, heihgt: frame.heihgt, data: new Uint8ClampedArray(frame.data), success(res) { console.log( 'OK' ) }, fail(res) { console.log( 'FAIL' ) } }) } nCounter++ if (nCounter >= 10) { nCounter = 0 } }) listener.start() } }) |
- 当前 Bug 的表现(可附上截图)
上面为相机控件显示的内容,下面为canvas显示onCameraFrame获取的frame数据,可见内容并不一致,主要表现是图像显示内容的范围不一致
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
一样的问题,
小米 红米Note 7 Pro; MIUI10.3; android 9 微信版本7.04
https://developers.weixin.qq.com/s/v6MrhIm97C8P