Android camera/picture orientation issues with Samsung Galaxy S3, S4, S5

后端 未结 4 824
你的背包
你的背包 2021-01-04 11:42

I am developing a camera application for Android API 16 to 21 which main and only purpose is to take portrait photo. I am able to take picture with several

4条回答
  •  执笔经年
    2021-01-04 12:30

    It is because the phone still save in landscape and put the meta data as 90 degree. You can try check the exif, rotate the bitmap before put in image view. To check exif, use something like below:

        int orientation = -1;
    
        ExifInterface exif = new ExifInterface(imagePath);
    
        int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 
                ExifInterface.ORIENTATION_NORMAL);
    
        switch (exifOrientation) {
            case ExifInterface.ORIENTATION_ROTATE_270:
                orientation = 270;
    
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                orientation = 180;
    
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                orientation = 90;
    
                break;
    
            case ExifInterface.ORIENTATION_NORMAL:
                orientation = 0;
    
                break;
            default:
                break;
        }
    

提交回复
热议问题