简体   繁体   中英

Save Image to Vertical with Android Studio and ImageView

一个问题是,有一种方法可以捕获照片并将其保存为垂直模式,无论是水平拍摄还是垂直拍摄?

Try to fix rotations of image according to your requirement.

Here is a sample:

ExifInterface ei = new ExifInterface(photoPath);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                                     ExifInterface.ORIENTATION_UNDEFINED);

switch(orientation) {

    case ExifInterface.ORIENTATION_ROTATE_90:
        rotateImage(bitmap, 90);
        break;

    case ExifInterface.ORIENTATION_ROTATE_180:
        rotateImage(bitmap, 180);
        break;

    case ExifInterface.ORIENTATION_ROTATE_270:
        rotateImage(bitmap, 270);
        break;

    case ExifInterface.ORIENTATION_NORMAL:

    default:
        break;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM