Android中Bitmap, Drawable, Byte,ID之间的转化
来源:互联网 发布:手机淘宝如何更换账号 编辑:程序博客网 时间:2024/04/30 06:33
1. Bitmap 转化为 byte
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
byte[] array= out.toByteArray();
2. byte转化为bitmap
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
3. bitmap转化为Drawable
Drawable drawable = new FastBitmapDrawable(bitmap);
4. Drawable转化为bitmap
a. BitmapDrawable, FastBitmapDrawable直接用getBitmap
b. 其他类型的Drawable用Canvas画到一个bitmap上
Canvas canvas = new Canvas(bitmap)
drawable.draw(canvas)
5.id转化graphic.drawable
Drawable drawable = getResources().getDrawable(R.drawable.icon);
6.id转化成Bitmap
Bitmap bitmap = BitmapFactory. decodeResource (Resources res, int id)
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
byte[] array= out.toByteArray();
2. byte转化为bitmap
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
3. bitmap转化为Drawable
Drawable drawable = new FastBitmapDrawable(bitmap);
4. Drawable转化为bitmap
a. BitmapDrawable, FastBitmapDrawable直接用getBitmap
b. 其他类型的Drawable用Canvas画到一个bitmap上
Canvas canvas = new Canvas(bitmap)
drawable.draw(canvas)
5.id转化graphic.drawable
Drawable drawable = getResources().getDrawable(R.drawable.icon);
6.id转化成Bitmap
Bitmap bitmap = BitmapFactory. decodeResource (Resources res, int id)
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- Android中Bitmap, Drawable, Byte,ID之间的转化
- android-Bitmap, Drawable, Byte之间的转化
- Android中Bitmap, Drawable, Byte之间的转化
- Android中Bitmap, Drawable, Byte之间的转化
- 蓝牙协议的命令和事件
- Java设计模式---简单工厂
- stm32 学习--创建项目
- 用Java 获得Access 数据库中的所有表名
- Android 使用 Intent 发送 email
- Android中Bitmap, Drawable, Byte,ID之间的转化
- PostgreSQL 类型转换
- ZooKeeper系列之二:Zookeeper常用命令
- 第十一周项目3-1-10000以内的回文数
- 人生
- 运动检测
- 蓝牙的HFP协议笔记
- http://www.coocox.org/CN/CoIDE/CoIDE_Updates.htm#
- android.widget.GridView