简体   繁体   English

使用Android Studio和ImageView将图像保存到垂直

[英]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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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