/**      * 根据指定的图像路径和大小来获取缩略图      *      * @param path      图像的路径      * @param maxWidth  指定输出图像的宽度      * @param maxHeight 指定输出图像的高度      * @return 生成的缩略图      */      public static Bitmap revitionImageSize(String path, int maxWidth, int maxHeight) throws IOException {          Bitmap bitmap = null;          try {              BufferedInputStream in = new BufferedInputStream(new FileInputStream(                      new File(path)));              BitmapFactory.Options options = new BitmapFactory.Options();              options.inJustDecodeBounds = true;              BitmapFactory.decodeStream(in, null, options);              in.close();              int i = 0;              while (true) {                  if ((options.outWidth >> i <= maxWidth)                          && (options.outHeight >> i <= maxHeight)) {                      in = new BufferedInputStream(                              new FileInputStream(new File(path)));                      options.inSampleSize = (int) Math.pow(2.0D, i);                      options.inJustDecodeBounds = false;                      bitmap = BitmapFactory.decodeStream(in, null, options);                      break;                  }                  i += 1;              }          } catch (Exception e) {              return null;          }          return bitmap;      }  

更多相关文章

  1. Android(安卓)批量上传sd卡图片
  2. Eclipse下搭建android开发环境
  3. katalon设置Android(安卓)SDK路径
  4. Android的FastBoot的安装与环境变量设置
  5. Weex 初体验(2)-navigator android跳转
  6. Qt for Android(安卓)环境搭建方法
  7. android studio配置android开发环境
  8. android 百度地图集成sdk,混淆报错(最新)
  9. Android(安卓)Studio - local path doesn't exist

随机推荐

  1. 《MySQL基础知识》笔记
  2. SQL语句字符串
  3. 内网安装mysql主从服务,mysql版本5.6.38-w
  4. 查询从每个组中查找第二大值
  5. 2018年5月05日 Python3-Mysql连接
  6. 数据库Mysql的学习(一)
  7. 解决Myeclipse下Debug出现Source not fou
  8. ORACLE 两表关联更新
  9. MySQL乐观锁在分布式场景下的实践
  10. 求sql存储过程!--创建存储过程统计各仓库