Page({
data: {},
onLoad() {
const cameraContext = wx.createCameraContext();
const fs = wx.getFileSystemManager();
const listener = cameraContext.onCameraFrame((frame) => {
console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height);
const filePath = `${wx.env.USER_DATA_PATH}/hello.jpg`;
fs.writeFile({
filePath,
encoding: "binary",
data: frame.data,
success: (res) => {
wx.saveImageToPhotosAlbum({
filePath,
});
},
});
});
listener.start();
setTimeout(() => listener.stop(), 2000);
},
});
保存后的图片显示已损坏且无法打开。
复现步骤:
- 真机调试 -> 二维码真机调试/自动真机调试
- 运行小程序2秒后查看真机相册
复现流程怎样的?
+1
+1