打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
android Camera 录像时旋转角度

录像保存时,旋转角度要与所拍录像时的角度保持一致,否则,看起来就会出现角度不度,巅倒等问题。

一般在开始录像之前会先去初始化录像

initializeRecorder 中会去读取当前的录像或拍照的旋转角度,并跟据当前的角度来选择一个角度写到所拍

照片或者视频的 exif 信息中去。

 1 // See android.hardware.Camera.Parameters.setRotation for   2         // documentation.   3         // Note that mOrientation here is the device orientation, which is the opposite of   4         // what activity.getWindowManager().getDefaultDisplay().getRotation() would return,   5         // which is the orientation the graphics need to rotate in order to render correctly.   6         int rotation = 0;   7         if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {   8             CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];   9             if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {  10                 rotation = (info.orientation - mOrientation + 360) % 360;  11             } else {  // back-facing camera  12                 rotation = (info.orientation + mOrientation) % 360;  13             }  14         } else {  15             //Get the right original orientation  16             CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];  17             rotation = info.orientation;  18         }  19 //        mMediaRecorder.setOrientationHint(rotation);  20   21         if (mCameraId == CameraInfo.CAMERA_FACING_FRONT) {  22             if (rotation == 270 || rotation == 90 || rotation == 180) {  23                 mMediaRecorder.setOrientationHint(180);  24             } else {  25                 mMediaRecorder.setOrientationHint(0);  26             }  27         } else {  28             if (rotation == 180){  29                 mMediaRecorder.setOrientationHint(180);  30             }else{  31                 mMediaRecorder.setOrientationHint(0);  32             }  33         }  

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
自己动手写一个Camera
Android相机开发详解
陀螺仪、加速计、磁力计等传感器汇总
Android4.2中Phone的P
高通camera架构 (二)
Android: Camera相机开发详解(上)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服