I also encountered such a problem, showing images in a list. But using EXIF ββdata, I managed to find a job to set the images in the correct orientation.
This was prepared raster object for display:
Matrix matrix = new Matrix(); matrix.postRotate(getImageOrientation(url)); Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
This is the method used in the second line above the code to rotate the orientation of images.
public static int getImageOrientation(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 (IOException e) { e.printStackTrace(); } return rotate; }
It may not be the exact answer to your question, it worked for me and I hope that it will be useful for you.
Shail adi
source share