private static int GetImageOrientation(Context context, Uri uri) { ContentResolver contentResolver = context.getContentResolver(); String[] columns = { MediaStore.Images.Media.DATA }; Cursor cursor = contentResolver.query(uri, columns, null, null, null); cursor.moveToFirst(); String path = cursor.getString(0); cursor.close(); int degree = 0; ExifInterface exifInterface = null; try { exifInterface = new ExifInterface(path); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int orientation = exifInterface .getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; default: break; } return degree; }
[…] 撮影された画像の傾きを返すメソッド 2014年1月24日 […]