public static int[] getImageWidthHeight(String path){
        BitmapFactory.Options options = new BitmapFactory.Options();

        /**
         * 最关键在此,把options.inJustDecodeBounds = true;
         * 这里再decodeFile(),返回的bitmap为空,但此时调用options.outHeight时,已经包含了图片的高了
         */
        options.inJustDecodeBounds = true;
        Bitmap bitmap = BitmapFactory.decodeFile(path, options); // 此时返回的bitmap为null
        /**
         *options.outHeight为原始图片的高
         */
        return new int[]{options.outWidth,options.outHeight};
    }

 

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-07-29
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-06-07
  • 2021-07-04
  • 2022-12-23
相关资源
相似解决方案