小飞侠发发发
小飞侠发发发
  • 发布:2025-06-09 18:36
  • 更新:2025-06-09 18:36
  • 阅读:11

安卓模式下plus.camera.getCamera()拍照旋转画面

分类:nvue

想请教一下uniapp 在安卓模式下,使用plus.camera.getCamera()拍照要怎么旋转摄像头呀,现有的画面是倒了90度。文档里参数好像不执行安卓端,都是微信小程序的参数。或者有没有什么别的办法可以直接在当前页面拍照,不跳转页面的,或预览页面的。直接点击拍照保存为图片后,我自己旋转图片也行。
let _this=this;
var cmr = plus.camera.getCamera();
cmr.captureImage(function (p) {
plus.io.resolveLocalFileSystemURL(p, function (entry) {
console.log('链接', entry.toLocalURL());
console.log('名称', entry.name);
const fullPath = entry.toLocalURL(); // 文件系统完整路径(如 file:///data/data/包名/files/xxx.jpg)
const absolutePath = entry.fullPath; // 绝对路径(如 /data/data/包名/files/xxx.jpg)

                    console.log('持久化路径:', p);  
                    console.log('完整路径:', fullPath);  
                    console.log('绝对路径:', absolutePath);  

                    // 4. 将路径保存到页面数据  
                    _this.cardInfoData.cameraImage = fullPath; // 推荐使用完整路径  
                    console.log('指定路径地址:', this.cardInfoData.cameraImage);  

                    // 5. 读取文件并转Base64(可选)  
                    entry.file((file) => {  
                        const fileReader = new plus.io.FileReader();  
                        fileReader.onloadend = (evt) => {  
                            const base64 = evt.target.result; // Base64数据(含Data URL前缀)  
                            _this.cardInfoData.cameraImageBase64 = base64;  
                            console.log('Base64数据:', base64);  
                        };  
                        fileReader.readAsDataURL(file);  
                    });  

                }, function (e) {  
                    plus.nativeUI.toast("读取拍照文件错误:" + e.message);  
                });  
            }, function (e) { }, {  
                filter: 'image'  
            });  
2025-06-09 18:36 负责人:无 分享
已邀请:

要回复问题请先登录注册