|
发表于 2023-4-4 09:48:12
2340 浏览 0 回复
Andorid10 8541E 相机应用修改成横屏后,出现的常见问题解决...
[QUESTION]
相机应用修改成横屏后,出现的常见问题解决方法...
[ANSWER]
首先要注意的是,展锐平台的相机应用DreamCamera2是基于竖屏手机设备开发的,未作横屏适配,非必要不建议把相机应用改为横屏,修改成横屏会导致mode的UI错位、部分功能无法使用、预览方向和成像方向不匹配等等许多问题。
根据不同项目需求可能会出现不同的问题,本faq旨在介绍如何将相机应用改为横屏,以及提供一些常见问题的解决方案。以Andorid10 8541E为例
修改成横屏
修改文件vendor\sprd\platform\packages\apps\DreamCamera2\Androidmanifest.xml,把android:screenOrientation的值"portrait"统统替换为"landscape"
修改ui角度,修改相机左下角缩略图旋转角度
- 修改文件vendor\sprd\platform\packages\apps\DreamCamera2\src\com\android\camera\widget\RoundedThumbnailView.java
- @Override
- public void setOrientation(int degree, boolean animation) {
- mEnableAnimation = animation;
- // make sure in the range of [0, 359]
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- + degree += 90;
复制代码
修改左滑显示的modelist列表图标角度
- 修改文件:vendor\sprd\platform\packages\apps\DreamCamera2\src\com\android\camera\ui\ModeSelectorItem.java
- @Override
- public void setOrientation(int degree, boolean animation) {
- Log.e(TAG, " setOrientation mCurrentDegree = " + degree);
- mEnableAnimation = animation;
- // make sure in the range of [0, 359]
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- + degree += 90;
- if (degree == mTargetDegree)
复制代码
修改相机顶部ui图标旋转角度
修改文件vendor\sprd\platform\packages\apps\DreamCamera2\src\com\android\camera\ui\RotateImageButton.java
- @Override
- public void setOrientation(int degree, boolean animation) {
- mEnableAnimation = animation;
- // make sure in the range of [0, 359]
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- + degree = degree + 90;
- if (degree == mTargetDegree)
- return;
- 修改相机拍照按钮旋转角度
- vendor\sprd\platform\packages\apps\DreamCamera2\src\com\android\camera\ui\RotateImageView.java
- public void setOrientation(int degree, boolean animation) {
- mEnableAnimation = animation;
- // make sure in the range of [0, 359]
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- + degree = degree + 90;
复制代码
修改预览角度
camera api1中可以通过setCameraDisplayOrientation()方法修改预览方向,但是camera api2没有旋转预览的相关接口,只能修改sensor_config.xml文件中对应camera id的<Orientation>角度值,可分别尝试使用0/90/180/270这四个值,具体按项目实际情况来定。
修改成像角度,旋转拍照照片角度
- Camera APP中,照片角度可通过 ANDROID_JPEG_ORIENTATION tag设置。
- DreamCamera2 APP的图片角度可以通过以下 mJpegRotation 来修改。
- src/com/android/camera/PhotoModule.java
- @Override
- public boolean capture() {
- .................................
- boolean isFrontCamera = info.isFacingFront();
- mJpegRotation = CameraUtil.getImageRotation(sensorOrientation,
- deviceOrientation, isFrontCamera); ////mJpegRotation为图片旋转的角度 可根据实际需求增加 90 180 270
- Log.i(TAG, " sensorOrientation = " + sensorOrientation
复制代码
旋转录像视频角度
Camera APP中,录像角度的修改通过 setOrientationHint(int degrees) 接口实现。
DreamCamera2 APP的录像角度可以通过以下rotation来完成
- src/com/android/camera/VideoModule.java
- private class VideoRecordStartTask extends AsyncTask<Void, Void, Void> {
- .................................
- @Override
- protected void onPostExecute(Void result) {
- .................................
- int rotation = CameraUtil.getImageRotation(sensorOrientation,
- deviceOrientation, isCameraFrontFacing()); ///录像旋转角度rotation 可根据实际需求增加 90 180 270
- /**
- * SPRD: Add for bug 585183, 3d video recoding @{
- * Original Code
- *
- mMediaRecorder.setOrientationHint();
- */
- mMediaRecorder.setOrientationHint(getRecorderOrientationHint(rotation)); //设置录像角度
复制代码
屏蔽无法适配横屏的功能
横屏之后目前无法适配的功能有全景、滤镜等,可以参考如下修改去除:
修改文件vendor\sprd\platform\packages\apps\DreamCamera2\src\com\android\camera\util\CameraUtil.java
- //去除全景
- public static boolean isWideAngleEnable() {
- - return 0 < wideAngleVersion && isBackCameraEnable;
- + //return 0 < wideAngleVersion && isBackCameraEnable;
- + return false;
- }
- //去除滤镜
- public static boolean isUseSprdFilter() {
- - return (mFilterVersion == 2);
- + //return (mFilterVersion == 2);
- + return false;
- }
- //去除慢动作
- public static boolean isSlowMotionEnabled() {
- - return isSlowMotionEnabled && isBackCameraEnable();
- + //return isSlowMotionEnabled && isBackCameraEnable();
- + return false;
- }
- //去除有声照片
- public static boolean isVoicePhotoEnable() {
- - return isVoicePhotoEnabled;
- + //return isVoicePhotoEnabled;
- + return false;
- }
- //去除二维码
- public static boolean isQrCodeEnabled(){
- - return isQrCodeEnabled && isBackCameraEnable;
- + //return isQrCodeEnabled && isBackCameraEnable;
- + return false;
- }
复制代码
|
|
手机微信同号:13682654092
|
|
|
|
|
登录或注册
|