[英]Photos taken in portrait are being saved in landscape
I've been trying to use the Android ACTION_IMAGE_CAPTURE
intent and ACTION_GET_CONTENT
intent to either take a photo or pick one. 我一直在尝试使用Android
ACTION_IMAGE_CAPTURE
意向和ACTION_GET_CONTENT
意向拍摄照片或选择照片。 The problem I'm having is that when I when I try to take a photo using the Android photo intent in portrait mode, it saves it in landscape orientation. 我遇到的问题是,当我尝试使用人像模式下的Android照片意图拍摄照片时,它将以横向保存。
I'm trying to save the Bitmap
of the correctly orientated photo from a URI string. 我正在尝试从URI字符串中保存正确定位的照片的
Bitmap
。
I found this question: Android Camera Intent Saving Image Landscape When Taken Portrait , which is the exact same problem I'm having, but the answer is incomplete and didn't work for me. 我发现了这个问题: 拍摄人像时Android相机意图保存图像风景 ,这与我遇到的问题完全相同,但是答案不完整,对我不起作用。 For example, what is the
resizedBitmap
, opts
, and is file
Uri.getPath()
? 例如,什么是
resizedBitmap
, opts
以及file
Uri.getPath()
?
Well some cameras lock the landscape mode as default mode of camera(Samsung note 2) so if you take a picture in potrait mode the image is still saved in landscape mode. 好吧,有些相机将风景模式锁定为默认相机模式(三星注释2),因此,如果您在纵向模式下拍摄照片,图像仍会保存为风景模式。 Most of the camera will add metadata into the image like the camera vendor, model,etc.
大多数相机都会将元数据添加到图像中,例如相机供应商,型号等。 Amongst various metadata that can be present the one we are intrested in is the rotation data.
可以呈现的各种元数据中有一个是旋转数据。 It specifies by what degrees the image is to be rotated.
它指定图像旋转的角度。 For knowing the rotation you can use ExifInterface class.
要了解旋转情况,可以使用ExifInterface类。
resizedBitmap Images are stored as bitmap objects in android. resizedBitmap图像在Android中存储为位图对象。 As an image can be large loading them whole into memory can lead to outofmemory error's and make your app consume more memory.
由于图像可能很大,因此将它们全部加载到内存中可能会导致内存不足错误,并使您的应用程序占用更多内存。 So a bitmap is first resized to appropriate size and then loaded into memory.
因此,首先将位图调整为适当的大小,然后再加载到内存中。
opts By opts you must be referring to BitmapFactory.Options method. opts通过opts必须引用BitmapFactory.Options方法。 It is a class that provides methods to change the behaviour of bitmaps like making it mutable(is set to true you can apply effects like grayscale to this bitmap) , find its height and width in pixels without loading it to RAM,etc.
这是一个提供更改位图行为的方法的类,例如使其可变(设置为true,可以将灰度等效果应用于此位图),以像素为单位查找其高度和宽度而无需将其加载到RAM等。
file Its a class used to perform CRUD operations in any file stored in the system. 文件它是用于在系统中存储的任何文件中执行CRUD操作的类。
Uri.getPath() this method returns the path where your image is stored or null. Uri.getPath()此方法返回存储图像的路径或为null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.