尝试从图库中获取图片,我的照片是:content://com.android.providers.media.documents/document/image%3A15672
当我不使用bmOptions(BitmapFactory.decodeStream(inStream))
时,我成功获得位图图像,但是当我添加bmOptions BitmapFactory.decodeStream(inStream,null,bmOptions))
时,我得到null
位图,无法弄清楚出错了什么。
private void setPic(Uri photoUri) {
InputStream inStream = null;
try {
inStream = getContentResolver().openInputStream(photoUri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
Log.i("response", "INPUT STREAM| Bitmap : "+ BitmapFactory.decodeStream(inStream,null,bmOptions));
}
答案 0 :(得分:1)
如果您使用bmOptions.inJustDecodeBounds = true;
,这是预期的行为,可以将其翻译为人类语言don't load the bitmap, just resolve it's size and some other metadata
。它通常用于在将Bitmap
大小加载到内存之前知道OOM
大小以防止出现With Worksheets("Demographic")
With .Range("AU2", .Cells(.Rows.count, "AU").End(xlUp))
Worksheets("Employee import").Range("F2").Resize(.Rows.count).Value = .Value
End With
End With
异常,并加载预先缩小的位图。