简体   繁体   English

Android中的相机/图片方向

[英]Camera/picture orientation in Android

I am working on an Android app that uses the phone's camera. 我正在使用手机摄像头的Android应用程序上工作。 When the picture is taken in a "standard orientation" (bottom of phone at the bottom or bottom of the phone to the right), the image received is as expected. 以“标准方向”(手机底部在手机底部或手机底部在右侧)拍摄照片时,接收到的图像符合预期。 On some phones, when the picture is taken in a "non-standard orientation" (bottom of the phone at the top or bottom of the phone to the left), the image received is upside down. 在某些手机上,当以“非标准方向”拍摄照片(手机底部在手机顶部或底部在左侧)时,接收到的图像是上下颠倒的。 On some phones, the camera application actually handles this and returns the image the expected way. 在某些手机上,相机应用程序实际上会处理此问题,并以预期方式返回图像。

My question is, since it seems to depend on the phone (manufacturer), is there a way to detect this and rotate the image as need without having to keep a hard coded list of phone types? 我的问题是,由于它似乎取决于电话(制造商),是否有办法检测到此情况并根据需要旋转图像,而不必保留电话类型的硬编码列表?

You will need to set the rotation on the camera device in order to get the correctly rotated image. 您将需要在摄像头设备上设置旋转角度以获得正确旋转的图像。 Try using - 尝试使用-

public void setRotation (int rotation)

Check the sample code provided here 检查此处提供的示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM