Nexus S 和 Samsung Galaxy S I9000 上的 ACTION_IMAGE_CAPTURE 方向问题
我正在尝试使用以下代码拍摄图片并将其存储到内部存储中:
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”文件中。
这个问题似乎只出现在三星 Galaxy S 设备(Galaxy S 和 Nexus S)上,这是我尝试过在图像拍摄期间根据方向自动旋转的另一台设备。
我将非常感谢有关该问题的任何帮助。
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);
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.
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.
I will very appreciate any help on that issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,发生这种情况是因为此 Intent 未设置 MediaStore.Images.ImageColumns.ORIENTATION 值。当事情通过普通相机应用程序进行时,它确实会被设置。
然而,在我的 Nexus S 上,该文件仍然获得正确的 EXIF 数据。所以你可以得到这样的方向:
然后你可以使用 use ContentResolver.update 添加正确的 ORIENTATION 数据。您只需将 ExifInterface 方向选项转换为旋转角度即可。
您的另一个选择是创建您自己的活动来操作相机硬件并记录文件。然后,您可以跟踪旋转和旋转。保存捕获的图像时将该值写入元数据。由于相机应用程序是 Android 的一部分,因此您可以复制并安装它。修改它没有太多痛苦。
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.On my Nexus S, however, the file still gets the correct EXIF data. So you could get the orientation like this:
Then you could use use ContentResolver.update add the correct ORIENTATION data. You just need to translate the ExifInterface orientation options to degrees rotated.
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.
我在三星手机上也遇到过这个问题,包括 Galaxy Ace(我将相机操作称为与您的完全不同的方法)
我的猜测是这是操作系统/硬件级别的问题。您是否尝试过使用本机相机应用程序拍照,并设法在该应用程序中获得正确的方向?
I have expereienced this issue also on the Samsung phones, including the Galaxy Ace, (I called the camera action an entirely different method from yours)
My guess is that this is the OS/hardware level issue. Have you tried taking a picture using the native camera application, and managed it to get the correct orientation in that app?