Captured Photo orientation is changing in android

后端 未结 5 2438
星月不相逢
星月不相逢 2020-11-30 13:05

I\'am opening camera app on click of a button. And displaying the captured photo in next activity. But the captured photo is rotating by 90 degrees. When I display the image

5条回答
  •  无人及你
    2020-11-30 13:15

    you can just simpaly rotate it

    get the orietation of the image taken using this code in onActvityresult ....

    File imageFile = new File(imageUri.toString());
           ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
           int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
           int rotate = 0;
           switch(orientation) {
             case ORIENTATION_ROTATE_270:
                 rotate-=90;break;
             case ORIENTATION_ROTATE_180:
                 rotate-=90;break
             case ORIENTATION_ROTATE_90:
                 rotate-=90;break
           }
    

提交回复
热议问题