你的位置:首页 > 软件开发 > 操作系统 > 关于android中调用系统拍照,返回图片是旋转90度

关于android中调用系统拍照,返回图片是旋转90度

发布时间:2016-05-26 00:00:25
转载博客:http://blog.csdn.net/walker02/article/details/8211628  项目开发中遇到的一个问题,对于三星手机在做手机照片选择时出现图片显示不正常,研究后发现应该是手机拍摄的图片旋转90度,有的图片旋转了180度,有的手机是正常的。 ...

  转载博客:http://blog.csdn.net/walker02/article/details/8211628

  项目开发中遇到的一个问题,对于三星手机在做手机照片选择时出现图片显示不正常,研究后发现应该是手机拍摄的图片旋转90度,有的图片旋转了180度,有的手机是正常的。在论坛里发现的一个方法,可以获取图片的属性,读取图片的旋转角度。

  /**   * 读取图片属性:旋转的角度   * @param path 图片绝对路径   * @return degree旋转的角度   */  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);        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;        }    } catch (IOException e) {        e.printStackTrace();    }    return degree;  }  /*  * 旋转图片   * @param angle   * @param bitmap   * @return Bitmap   */   public static Bitmap rotaingImageView(int angle , Bitmap bitmap) {     //旋转图片 动作      Matrix matrix = new Matrix();;     matrix.postRotate(angle);     System.out.println("angle2=" + angle);     // 创建新的图片      Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,         bitmap.getWidth(), bitmap.getHeight(), matrix, true);     return resizedBitmap;   }

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:关于android中调用系统拍照,返回图片是旋转90度

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录