相机/图片方位的Andr​​oid [英] Camera/picture orientation in Android

查看:96
本文介绍了相机/图片方位的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序,使用手机的摄像头。当照片拍摄于一个标准方向(手机在手机的右侧底部或底部底部),图像接收的预期。在某些手机中,当拍摄图像中一个非标准方向(电话的底部在手机的顶部或底部的左侧)中,接收的图像是上下颠倒。在一些手机,相机应用程序实际上处理这一点,并返回图像以预期的方式。

I am working on an Android app that uses the phone's camera. 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.

我的问题是,因为它似乎取决于手机(制造商),有什么方法来检测这一点,并旋转图像的需求,而无需保持手机类型的硬codeD列表?

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)

检查所提供的示例code <一个href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29">here

这篇关于相机/图片方位的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆