BitmapFactory.decodeResource and drawable* folders

送分小仙女□ 提交于 2019-12-05 15:47:23

问题


I am wondering if decodeResource (Resources res, int id, BitmapFactory.Options opts) takes into account the drawable-ldpi,mdpi,hdpi etc. folders.

I checked the source code, and it doesn't look like that, but I may be missing something.

(Generally, where are the R.drawable. resolved in Android source? I was unable to find it.)


回答1:


Yes it takes it into account. For example if you do :

Resources res = getContext().getResources();
int id = R.drawable.image; 
Bitmap b = BitmapFactory.decodeResource(res, id);

The bitmap will be different if "image" is present in all of the drawables folders. So I think using the overloaded method decodeResource (Resources res, int id, BitmapFactory.Options opts) will work in the same way.



来源:https://stackoverflow.com/questions/11756231/bitmapfactory-decoderesource-and-drawable-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!