我在我的Android应用中创建了一个自定义相机活动,但是当我在下一个活动中根据它所采用的设备显示时,图像被旋转了90度。这只发生在特定的设备上。我想弄清楚这个问题。
答案 0 :(得分:1)
使用以下代码,将其传递给您的路径:
try {
ExifInterface exif = new ExifInterface(picturePath);
orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Matrix m = new Matrix();
if ((orientation == ExifInterface.ORIENTATION_ROTATE_180)) {
m.postRotate(180);
Log.e("in orientation", "" + orientation);
bitmap = Bitmap.createBitmap(thumbnail, 0, 0,
thumbnail.getWidth(), thumbnail.getHeight(), m,
true);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
m.postRotate(90);
Log.e("in orientation", "" + orientation);
bitmap = Bitmap.createBitmap(thumbnail, 0, 0,
thumbnail.getWidth(), thumbnail.getHeight(), m,
true);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
m.postRotate(270);
Log.e("in orientation", "" + orientation);
bitmap = Bitmap.createBitmap(thumbnail, 0, 0,
thumbnail.getWidth(), thumbnail.getHeight(), m,
true);
}
} catch (Exception e) {
}