bitmap 和 drawable 转化
2016-06-29 17:11
246 查看
1 Bitmap 转成 Drawable
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=new BitmapDrawable(bm);
因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
2 R.drawable.ic_launcher转Bitmap
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launch);
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)
3 Drawable 转成 Bitmap
BitmapDrawable bd=(BitmapDrawable)drawable;
Bitmap bitmap=bd.getBitmap();
String fileName = "/data/data/com.test/aa.png;
Bitmap bm = BitmapFactory.decodeFile(fileName);
iv.setImageBitmap(bm);
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=new BitmapDrawable(bm);
因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
2 R.drawable.ic_launcher转Bitmap
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),R.drawable.ic_launch);
mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)
3 Drawable 转成 Bitmap
BitmapDrawable bd=(BitmapDrawable)drawable;
Bitmap bitmap=bd.getBitmap();
String fileName = "/data/data/com.test/aa.png;
Bitmap bm = BitmapFactory.decodeFile(fileName);
iv.setImageBitmap(bm);
相关文章推荐
- Java Web总结(二)-- 上传和下载
- OpenCV 3.0中IplImage* 转cv::Mat
- Java集合源码分析(一)
- spring定时器配置为整点执行
- 医学扫盲 —— 身体篇
- PXE实现批量安装部署(win与linux系统)
- 一些程序段分析(1)
- 梯度下降法实现softmax回归MATLAB程序
- 深入理解Android消息处理系统——Looper、Handler、Thread
- springmvc在线教程
- iOS 开发 获取IP地址
- 为什么要BI(商业智能)
- 11个JavaScript颜色选择器插件
- 5W2H+35问
- springmvc在线教程
- 实验四、存储管理
- 实验三、进程调度模拟程序
- 重构表索引
- linux socket 缓冲区默认大小
- Spring集成Quartz定时任务框架介绍和Cron表达式详解