hac*_*ker 5 camera android exif
我在我的应用程序中处理相机图像实际上是作为网址.相机应用程序处于纵向模式.因此图像有时会保持旋转或向右旋转.我知道我们可以使用EXIF从图库正常图像方向,我们可以检查exif值并进行适当的更改.这是exif的代码
ExifInterface exif = new ExifInterface("filepath");
exif.getAttribute(ExifInterface.TAG_ORIENTATION);
Run Code Online (Sandbox Code Playgroud)
所以我的问题是在我的情况下什么是文件路径,它是网址本身还是我应该为此创建一个文件..任何帮助将不胜感激....
小智 1
首先,你必须在onActiviryResult中获取Uri,就像这里
拍照后在onActivityResult中获取图像Uri?
然后,当你有 Uri 时,你可以像这样获取文件路径: String filepath = getRealPathFromURI(someUri);
public String getRealPathFromURI(Uri contentUri) {
String res = null;
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
if(cursor != null && cursor.moveToFirst()){;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
res = cursor.getString(column_index);
}
cursor.close();
return res;
}
Run Code Online (Sandbox Code Playgroud)
然后,如果文件路径不为空且不为空,则可以获取 EXIF 数据,检查它并根据需要旋转图像。
希望它会有所帮助。
| 归档时间: |
|
| 查看次数: |
1210 次 |
| 最近记录: |