开发者

Orientation of captured image using built-in Camera application

I have invoked the built-in Camera application in android 2.1 using intent. I've used the following code:

Intent cameraintent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "MyTestFile.jpg");
cameraintent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
outputFileUri = Uri.fromFile(file);
startActivityForResult(cameraintent, CAMERA_PIC_REQUEST);

To get the orientation of the captured image I've used the following code:

Uri capturedIm开发者_Python百科age = outputFileUri;
Bitmap theBmp = MediaStore.Images.Media.getBitmap(getContentResolver(), capturedImage);
int img_orient=0;                       
String[] projection = { MediaStore.Images.Media.ORIENTATION };
Cursor mImageCursor = managedQuery(capturedImage, projection, null, null, null);

I am not able to get the orientation of captured photo as the cursor mImageCursor is always null. What is problem in my code?


You could try using the ExifInterface class to read out the information instead. Alternatively, it's very possible that the photo has none. Some devices rotate the photos and save them without setting the orientation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜