在Nexus S和三星Galaxy S I9000 ACTION_IMAGE_CAPTURE定位问题 [英] ACTION_IMAGE_CAPTURE orientation problem on Nexus S and Samsung Galaxy S I9000
问题描述
我想拍摄照片,并将其存储到内部存储通过以下code:
I'm trying to shoot picture and store it into internal storage by using the following code:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
takenPhoto = new File(uploadsFolder, getNewPicFileName());
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(takenPhoto));
startActivityForResult(intent, SHOOT_MEDIA_REQUEST_CODE);
问题是,在Nexus S和Galaxy S的设备的默认和ACTION_IMAGE_CAPTURE意向单方向为横向。如果我拍的画面在纵向模式下,那张照片存储到takenPhoto文件旋转。
The problem is that on Nexus S and Galaxy S devices default and the single orientation for ACTION_IMAGE_CAPTURE intent is landscape. If i shoot picture in portrait mode, that picture is stored into "takenPhoto" file rotated.
这问题似乎只出现在三星Galaxy S设备(银河S和Nexus S的),另一个设备我试图使自动旋转取决于在图像拍摄方向。
That problem seems appearing only on Samsung Galaxy S devices (Galaxy S and Nexus S), another devices i tried make auto-rotate depending on orientation during image shooting.
我会非常AP preciate关于该问题的任何帮助。
I will very appreciate any help on that issue.
推荐答案
据我所知,这种情况正在发生,因为 MediaStore.Images.ImageColumns.ORIENTATION
值ISN 'T由这个意图设置。它被置在事情来通过正常的摄像头应用程序。
From what I can tell, this is happening because the MediaStore.Images.ImageColumns.ORIENTATION
value isn't being set by this Intent. It does get set when things come through the normal camera app.
在我的Nexus S,但是,文件仍然得到正确的EXIF数据。所以,你可以得到的方向是这样的:
On my Nexus S, however, the file still gets the correct EXIF data. So you could get the orientation like this:
ExifInterface exif = new ExifInterface("filepath");
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
然后就可以使用使用<一个href="http://developer.android.com/reference/android/content/ContentResolver.html#update%28android.net.Uri,%20android.content.ContentValues,%20java.lang.String,%20java.lang.String%5B%5D%29"相对=nofollow> ContentResolver.update 添加正确的方向数据。你只需要翻译ExifInterface方向选择,旋转度。
Then you could use use ContentResolver.update add the correct ORIENTATION data. You just need to translate the ExifInterface orientation options to degrees rotated.
您的另一种选择是创建自己的活动来操作相机硬件和记录文件。然后你会跟踪旋转和放的;保存拍摄的图像时,写入值到元。由于相机应用的是Android的一部分,你也许可以复制和;修改,而不会太多的痛苦。
Your other option is to create your own Activity to operate the camera hardware and record the file. You'd then keep track of rotations & write the value into the metadata when saving a captured image. Since the Camera app is part of Android, you could probably copy & modify it without too much pain.
这篇关于在Nexus S和三星Galaxy S I9000 ACTION_IMAGE_CAPTURE定位问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!