把本地的int类型的图片转换成drawable、Bitmap
2016-03-25 21:04
351 查看
获取本地图片
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对象即可。
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对象即可。
相关文章推荐
- ext2文件系统源代码之xattr_user.c
- 三言两语说shader(二)黑屏效果
- 这是一篇资源博客
- sizeof
- 读入优化模板
- 【bzoj1029】[JSOI2007]建筑抢修
- 【bzoj1042】[HAOI2008]硬币购物
- 二叉树中和为某一值的路径
- 84. Largest Rectangle in Histogram
- mysql导出视图以及表结构
- ext2文件系统源代码之xattr_trusted.c
- 第一遍 第一章
- ( Leetcode 92 ) Reverse Linked List II
- 利用bind启动service
- 【bzoj2748】[HAOI2012]音量调节
- Spring AOP中pointcut expression表达式解析
- ext2文件系统源代码之xattr.c
- prj文件所在目录
- Git基础知识与常用命令
- 【bzoj2743】[HEOI2012]采花