android获取图片的旋转角度

public static int getExifOrientation(String filepath) {
    int degree = 0;
    ExifInterface exif = null;
    try {
        exif = new ExifInterface(filepath);
    } catch (IOException ex) {
    	Log.d(TAG, "cannot read exif" + ex);
    }
    if (exif != null) {
	int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
        if (orientation != -1) {
            switch(orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    degree = 90;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    degree = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    degree = 270;
                    break;
            }
        }
    }
    return degree;
}


android获取图片的旋转角度

android获取图片的旋转角度,布布扣,bubuko.com

android获取图片的旋转角度

上一篇:Python的基本语法,涵盖数据类型、循环判断、列表、map和set等


下一篇:(Android review)打开Activity返回结果