Bitmap和Drawable相互转换方法
来源:互联网 发布:sql最大值函数 编辑:程序博客网 时间:2024/05/18 03:57
Bitmap和Drawable相互转换方法
很多开发者表示,不知道Android的Drawable和Bitmap之间如何相关转换。下面Android123给大家两种比较简单高效的方法。
一、Bitmap转Drawable
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=BitmapDrawable(bm);
Android开发网提示因为BtimapDrawable是Drawable的子类,最终直接使用bd对象即可。
二、 Drawable转Bitmap
转成Bitmap对象后,可以将Drawable对象通过Android的SK库存成一个字节输出流,最终还可以保存成为jpg和png的文件。
Drawable d=xxx; //xxx根据自己的情况获取drawable
BitmapDrawable bd = (BitmapDrawable) d;
Bitmap bm = bd.getBitmap();
最终bm就是我们需要的Bitmap对象了。
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Android Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法!!!
- Android Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- android:Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- android:Bitmap和Drawable相互转换方法
- Bitmap和Drawable相互转换方法
- Android:Bitmap和Drawable相互转换方法
- android:Bitmap和Drawable相互转换方法
- 我的两个自动注入@Autowired,在控制层和服务层
- hdu 过山车(匈牙利算法)
- SEDA介绍与分析
- 学习使用SQLite(版本3.7.4)(中F)
- C#生成随机验证码
- Bitmap和Drawable相互转换方法
- log buffer —— log file switch completion
- 基于主特征空间相似度计算的切分算法
- Spring For Android初体验
- python 将python程序编译成可执行文件
- ios 编码规范
- cvs如何忽略掉已添加的目录
- 深入Session(摘录)
- 【js特效】一款很漂亮的相册效果