android

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.


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:

ExifInterface exif = new ExifInterface("filepath");
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                     ExifInterface.ORIENTATION_NORMAL);

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.


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?

链接地址: http://www.djcxy.com/p/7206.html

上一篇: IE忽略!在CSS中的重要标签

下一篇: 安卓