Android中Bitmap, Drawable, Byte,ID之间的转化
来源:互联网 发布:兰蔻小黑瓶眼膜霜 知乎 编辑:程序博客网 时间:2024/04/28 15:24
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
Drawabledrawable=activity.getResources().getDrawable(R.drawable.icon);
6 . id转化成Bitmap
Bitmap bitmap = BitmapFactory. decodeResource (Resources res, int id)
0 0
- 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之间的转化
- 教你建立数据分析的思维框架
- Atom 编辑器安装 linter-eslint 插件,并配置使其支持 vue 文件中的 js 格式校验
- mongodb学习日记一--------------------------安装及注意事项
- cmake使用介绍【转】
- JavaWeb开发基础——JavaScript(一)
- Android中Bitmap, Drawable, Byte,ID之间的转化
- softmax 回归原理及python实现
- Parade。。。。
- 百度地图坐标定位
- 每日积累小细节
- mongodb学习日记二--------------------------常用操作
- Classifying MNIST digits using Logistic Regression 代码个人,理解
- GLSL学习第一课笔记记录
- amazon web services的一些知识