zoukankan      html  css  js  c++  java
  • 读取图片旋转角度并转正

    有的手机拍出来的照片是被旋转过得,此时,需要先旋转回正常的角度,再进行处理

    读取图片旋转角度

    public static int readPictureDegree(String path) {
        int degree = 0;
        try {
            ExifInterface exifInterface = new ExifInterface(path);
            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
            LogW.out("readPictureDegree : orientation = " + orientation);
            if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
                degree = 90;
            } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
                degree = 180;
            } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
                degree = 270;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return degree;
    }

    旋转图片

    public static Bitmap rotateBitmap(int angle, Bitmap bitmap) {
        Matrix matrix = new Matrix();
        matrix.postRotate(angle);
        Bitmap rotation = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
                matrix, true);
        return rotation;
    }
  • 相关阅读:
    PHP中pack、unpack的详细用法
    Rbac
    composer
    tp5+workman
    apache
    Vs2005安装后没有模板的解决方法
    java中使用mysqldump 备份数据库
    java中文件上传下载将file转为MultipartFile
    hibernate中的schema
    Java之 1.8新特性
  • 原文地址:https://www.cnblogs.com/wenhui92/p/6242691.html
Copyright © 2011-2022 走看看