相机定位问题,在安卓 [英] Camera orientation issue in Android

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

问题描述

我建立一个使用相机拍照的应用程序。下面是我的源$ C ​​$ C要做到这一点:

I am building an application that uses camera to take pictures. Here is my source code to do this:

        File file = new File(Environment.getExternalStorageDirectory(),
            imageFileName);
    imageFilePath = file.getPath();
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    //Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    startActivityForResult(intent, ACTIVITY_NATIVE_CAMERA_AQUIRE);

onActivityResult()的方法,我用 BitmapFactory.de codeStream()皮卡图像

On onActivityResult() method, I use BitmapFactory.decodeStream() to pickup the image.

当我在Nexus One上运行我的应用程序,它运行良好。但是,当我运行在三星Galaxy S或宏达启发4G,图像的方向是不正确的。

When I run my application on Nexus one, it runs well. But when I run on Samsung Galaxy S or HTC Inspire 4G, the image's direction is not correct.

  • 捕捉人像模式,真正的图像(保存在SD卡)总是旋转90度。 (拍摄后图像preVIEW)(SD卡实际图像)

  • Capture with portrait mode, the real image (save on SD card) always rotates 90 degree. (image preview after shot) (real image on SD card)

与风景模式捕捉,所有的东西都是好的。

Capture with landscape mode, all things are good.

(拍摄后图像preVIEW)(SD卡实像)图像

(image preview after shot) (real image on SD card)

请帮我解决这个问题。

感谢。

推荐答案

有不少类似的题目和问题在这里。既然你不写你自己的相机,我认为它归结为:

There are quite a few similar topics and issues around here. Since you're not writing your own camera, I think it boils down to this:

一些设备保存,而其他人只需将方向标记在照片的EXIF数据之前,旋转图像。

some devices rotate the image before saving it, while others simply add the orientation tag in the photo's exif data.

我建议你检查照片的EXIF数据,并寻求特别是对

I'd recommend checking the photo's exif data and looking particularly for

ExifInterface exif = new ExifInterface(SourceFileName);     //Since API Level 5
String exifOrientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);

由于照片是在应用程序中正确显示,我不知道问题出在哪里,但一定要设置您在正确的道路上!

Since the photo is displaying correctly in your app, i'm not sure where the problem is, but this should definitely set you on the right path!

这篇关于相机定位问题,在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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