转换Bitmap to Drawable
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;
Drawable drawable = (Drawable)bitmapDrawable;
Bitmap bitmap = new Bitmap (...);
Drawable drawable = new BitmapDrawable(bitmap);
转换Drawable to Bitmap
Drawable d = ImagesList.get(0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
转换Bitmap to byte[]
private byte[] Bitmap2Bytes(Bitmap bm){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}
转换byte[] to Bitmap
private Bitmap Bytes2Bimap(byte[] b){
if(b.length!=0){
return BitmapFactory.decodeByteArray(b, 0, b.length);
}else {
return null;
}
}
分享到:
相关推荐
Android Drawable、Bitmap、byte、灰度 转换
详细的介绍了android_Drawable、Bitmap、byte[]之间的转换 在android开发中非常实用
Android Drawable、Bitmap、byte、灰度 之间的转换
android 画图 bitmap drawable canvas paint
文档中描述了Drawable Bitmap 几种转换方法供初学者使用。方法都是经过实践验证的。
Android Drawable和Bitmap的转换实例详解 通常我们需要通过代码去设置图片,就需要设置图片Bitmap和Drawable的转换,下面整理了几种方式 一、Bitmap转Drawable Bitmap bm=xxx; //xxx根据你的情况获取 ...
一个在VC中将Bitmap转换为Byte[]的小例子。
android bitmap通过byte数组以流的形式创建,自己加了进度条,看起来稍微好点
很多开发者表示,不知道Android的Drawable和Bitmap之间如何相关转换。下面Android123给大家两种比较简单高效的方法。 一、Bitmap转Drawable 代码如下: Bitmap bm=xxx; //xxx根据你的情况获取 BitmapDrawable bd...
将Bitmap转成byte[],进行保存,用到时再取出byte[],转化成Bitmap,进行显示
Drawable Bitmap InputStream byte[]相互转化工具类,单例模式
Android图片Bitmap和字符串String之间相互转换的工具类,外加项目代码,封装好的,直接可以用,
android bitmap outofMemory 用来解决android中常见的bitmap outOfMemory
将图片由bitmap类型转换为stream类型再转换为byte[]类型,然后再还原
Android不支持将Bitmap转换成单色的Bmp图片,所以参考Bmp格式说明,自己写了一个转换类。亲测有效!!!
Drawable Bitmap之间的转化Drawable Bitmap之间的转化
android Bitmap相关知识介绍~~~
android Bitmap用法总结 Bitmap用法总结 1、Drawable → Bitmap public static Bitmap drawableToBitmap(Drawable drawable) { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable....
主要介绍了Android Bitmap和Drawable的对比的相关资料,需要的朋友可以参考下