BitmapFactory.decodeResource和drawable *文件夹 [英] BitmapFactory.decodeResource and drawable* folders

查看:778
本文介绍了BitmapFactory.decodeResource和drawable *文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

(通常,R.drawable在Android源代码中的哪里解析?我找不到它.)

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

推荐答案

是的,它已将其考虑在内.例如,如果您这样做:

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);

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

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.

这篇关于BitmapFactory.decodeResource和drawable *文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆