[英]Android custom portrait camera and images orientation
I am writing a custom portrait camera and I am having some issues with images orientation. 我正在编写自定义肖像相机,图像方向出现问题。 In details, I need always the camera to be in portrait orientation and it happens using the manifest configuration:
详细来说,我总是需要使相机保持纵向,并且使用清单配置来实现:
android:screenOrientation="portrait" android:screenOrientation =“ portrait”
and I set in application: 我在应用程序中设置:
customCamera.setDisplayOrientation(90);
which works, because when I rotate the device (90,180,270 degrees) I can see (from camera preview) the right image. 之所以有效,是因为当我旋转设备(90,180,270度)时,可以从相机预览中看到正确的图像。
I don't care when the device orientation is locked (disabled), but when it's enabled, it seems that I don't get any orientation change. 我不在乎何时锁定设备方向(禁用),但是在启用设备时,似乎没有任何方向更改。 I always get 0 degrees using the code:
我总是使用以下代码获得0度:
getWindowManager().getDefaultDisplay().getRotation();
Technically, I need to write to the taken picture (using exif data) 0,1,3,6 or 8 value. 从技术上讲,我需要将拍摄的图片(使用exif数据)写入0、1、3、6或8值。 So, the steps are: 1) set the right orientation on custom portrait camera - DONE!
因此,步骤如下:1)在自定义人像相机上设置正确的方向-完成! 2) Preview the right picture - DONE!
2)预览正确的图片-完成! 3) If the device orientation in enabled, get the current rotation (0.90,180,270 degrees) 4) Write the taken picture with the right orientation exif tag.
3)如果启用了设备方向,则获取当前旋转角度(0.90,180,270度)。4)使用正确的方向exif标签写入所拍摄的照片。
I am using Samsung Galaxy I for the development. 我正在使用Samsung Galaxy I进行开发。
The question is: How can i get the device orientation when the application shows always a custom portrait camera, which should never be rotated, but the device orientation is enabled? 问题是:当应用程序始终显示自定义人像相机(永远不应该旋转但启用了设备方向)时,如何获得设备方向?
Thank you, Nikolaos 谢谢尼古拉斯
You can use OrientationEventListener 您可以使用OrientationEventListener
OrientationEventListener mOrientationListener = new OrientationEventListener(
this, SensorManager.SENSOR_DELAY_NORMAL) {
@Override
public void onOrientationChanged(int orientation) {
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.