您的位置:首页 > 其它

把本地的int类型的图片转换成drawable、Bitmap

2012-08-06 11:46 302 查看
转自:http://www.maxiaoguo.com/shipin/343.html

获取本地图片

Bitmap decodeResource = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_default_user_bg_34);

把本地的int类型的图片转换成drawable

Drawable drawable = context.getResources().getDrawable(R.drawable.left);

把本地的int类型的图片转换成Bitmap

Resources r = this.getContext().getResources();

Inputstream is = r.openRawResource(R.drawable.my_background_image);

BitmapDrawable bmpDraw = new BitmapDrawable(is);

Bitmap bmp = bmpDraw.getBitmap();

Bitmap转Drawable

Bitmap bm=xxx; //xxx根据你的情况获取

BitmapDrawable bd=BitmapDrawable(bm);

因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: