sga*_*man 24 camera android exif photo orientation
我需要知道图库中图像的方向(由相机拍摄).我最初的方法是使用适用于我的Droid 1的MediaStore.Images.Media.ORIENTATION.在HTC Thunderbolt上测试时,手机只能将0保存到该字段.
然后我开始阅读exif数据:
ExifInterface exifReader = new ExifInterface(mFilePath);
exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
Run Code Online (Sandbox Code Playgroud)
这也为每个图像返回0.任何人都有关于如何正确获取Android照片的方向的想法?
dba*_*ugh 28
这是我在我的活动中使用onActivityResult()的代码.返回的意图是选择图像/*类型的图像.对我来说效果很好!
Uri imageUri = intent.getData();
String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
Cursor cur = managedQuery(imageUri, orientationColumn, null, null, null);
int orientation = -1;
if (cur != null && cur.moveToFirst()) {
orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0]));
}
Matrix matrix = new Matrix();
matrix.postRotate(orientation);
Run Code Online (Sandbox Code Playgroud)
我的解决方案
从exif数据中删除任何方向检查.我找不到一个准确的实例.
使用标准String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
来获得方向.
如果这是0
使用decodeStream ...
Run Code Online (Sandbox Code Playgroud)if(o.outHeight > o.outWidth){ //set orientation to portrait }
否则就是风景
归档时间: |
|
查看次数: |
25726 次 |
最近记录: |