BitmapFactory.decodeResource和drawable*文件夹

Tho*_*alc 11 android bitmap drawable android-resources

我想知道是否decodeResource (Resources res, int id, BitmapFactory.Options opts)考虑drawable-ldpi,mdpi,hdpi等文件夹.

我检查了源代码,它看起来不像那样,但我可能会遗漏一些东西.

(一般来说,R.drawable.在Android源代码中已解决?我无法找到它.)

fla*_*yte 39

是的,它会考虑到它.例如,如果你这样做:

Resources res = getContext().getResources();
int id = R.drawable.image; 
Bitmap b = BitmapFactory.decodeResource(res, id);
Run Code Online (Sandbox Code Playgroud)

如果所有drawables文件夹中都存在"image",则位图将不同.所以我认为使用重载方法decodeResource (Resources res, int id, BitmapFactory.Options opts)将以相同的方式工作.