So I noticed that on some devices my captured image (bitmap) is weirdly rotated - to 90 degrees usually. I did create a function that can rotate it correctly, but the problem now is, that sometimes the image comes in (is captured) perfectly okay. Is there a way I can find out if captured image is rotated (it's orientation)?
I found a code fragment like this:
try {
ExifInterface exif = new ExifInterface(filename);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
int rotate = 0;
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate-=90;break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate-=90;break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate-=90;break;
}
...
}
But ExifInterface exif = new ExifInterface(filename);
expects a file or file uri to be created. Does this mean I have to change my bitmap to file first and then use this approach or is there other ways to fight with this thing?
P.S. I'm using Android's Camera X