bitmapFactoryOptions.outWidth and Height are returning -1



我有一个相机拍摄的图片文件。

路径是

/storage/emulated/0/Android/data/com.xxxxxxxxxxxx.yyyyyyyyyyyyy/files/Pictures/yyyyyyyyyyyyyyy_overviewPicture_17417005982933606358.jpg

使用文件文件 = 新文件(路径名(,我得到一个有效的文件,大小约为 25 MB :-(

法典

BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(pathName,bmOptions);
int inSampleSize = Math.min(bmOptions.outWidth/App.PICTURE_WIDTH_MAX,bmOptions.outHeight/App.PICTURE_HEIGHT_MAX);

我尝试获取 x 和 y 值以缩小它。 但两个值都只返回 -1。有什么想法吗?

应用级别与目标28.23-28

图片文件的大小为 0,因此无法编码。我万万没想到。我建议检查

if(new File(pathName).length() == 0) return false

或类似尝试解码之前。感谢阅读/评论!

最新更新