【发布时间】:2012-10-23 20:20:12
【问题描述】:
我正在从我的肖像相机应用程序中拍照并发送到服务器。在发送之前,我需要在必要时旋转图像。所以我将图像保存在 sdcard 中并尝试获取 Exif 或 Cursor。我经历了大多数与此相关的帖子。但对我没有任何作用。这是代码..
-
ExifInterface
File imageFile = new File(uri.toString()); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);这里任何图像的方向总是 0
-
光标
int orientation = 0; final String[] projection = new String[] { MediaStore.Images.Media.ORIENTATION }; final Cursor cursor = getApplicationContext() .getContentResolver().query(uri, projection, null, null, null); if (cursor != null) { final int orientationColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.ORIENTATION); if (cursor.moveToFirst()) { orientation = cursor.isNull(orientationColumnIndex) ? 0 : cursor.getInt(orientationColumnIndex); }这里的图像旋转也是零。我怎样才能找到图像的确切旋转?任何帮助将不胜感激..
【问题讨论】:
-
运气好吗?有类似的问题吗?
-
嗨!我有完全相同的问题。 exif 总是返回 0 光标总是为空……你解决了吗?
标签: android-camera android-orientation android-cursor