Bitmap Drawable bitByte[] 互相转换
来源:互联网 发布:ubuntu设置开机自启 编辑:程序博客网 时间:2024/05/21 17:13
(1)转换Bitmap to Drawable
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;
Drawable drawable = (Drawable)bitmapDrawable;
Bitmap bitmap = new Bitmap (...);
Drawable drawable = new BitmapDrawable(bitmap);
(2)转换Drawable to Bitmap
Drawable d = ImagesList.get(0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
(3)转换Bitmap to byte[]
private byte[] Bitmap2Bytes(Bitmap bm){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}
(4)转换byte[] to Bitmap
private Bitmap Bytes2Bimap(byte[] b){
if(b.length!=0){
return BitmapFactory.decodeByteArray(b, 0, b.length);
}else {
return null;
}
}
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;
Drawable drawable = (Drawable)bitmapDrawable;
Bitmap bitmap = new Bitmap (...);
Drawable drawable = new BitmapDrawable(bitmap);
(2)转换Drawable to Bitmap
Drawable d = ImagesList.get(0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
(3)转换Bitmap to byte[]
private byte[] Bitmap2Bytes(Bitmap bm){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}
(4)转换byte[] to Bitmap
private Bitmap Bytes2Bimap(byte[] b){
if(b.length!=0){
return BitmapFactory.decodeByteArray(b, 0, b.length);
}else {
return null;
}
}
- Bitmap Drawable bitByte[] 互相转换
- Drawable和Bitmap互相转换
- android中bitmap和drawable互相转换
- Bitmap和Drawable的互相转换
- 图片drawable与bitmap格式互相转换
- Bitmap和Drawable互相转换的方法
- Bitmap和drawable的互相转换
- android Drawable Bitmap转换
- Bitmap Drawable相互转换
- Drawable和Bitmap转换
- drawable与bitmap转换
- Drawable和Bitmap转换
- Bitmap转换为Drawable
- Drawable和Bitmap转换
- Drawable和Bitmap转换
- Drawable向bitmap转换
- Drawable和Bitmap转换
- Drawable 转换Bitmap
- JAVA中MD5加密和Base64加密解密算法
- android sdk 编译--如何将源代码加入android.jar,以及make原理 1
- 23、成为Oracle 10g DBA之路
- android sdk 编译--如何将源代码加入android.jar,以及make原理 2
- 应该过初试了,继续努力,阿杜
- Bitmap Drawable bitByte[] 互相转换
- android小记之Animation4种动画效果(贴上了GIF图)
- 心情小记
- 黑马程序员_王康Java常用集合类
- 报表制作工具 FineReport_JS整理
- 四层和七层负载均衡的区别
- NoSQL 百科
- js去空格
- 深入浅出Powershell——部署UDCX