获取三星手机本地相册图片时,如何解决图片的旋转问题

用SharePhoto获取本地相册图片时,三星手机显示的图片总是被旋转90度,如何在获取本地图片的时候直接显示正常的图样,求帮忙大神解答

你是不是把图片的文件名写成.png了?改成.jpg试试。JPEG图片里面Exif字段存储图片方便,下面这个方法你可以参考一下

public static int getCameraPhotoOrientation(String imagePath) {
int rotate = 0;
try {
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(
imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (Exception e) {
}
return rotate;
}