[android]代码库
将Bitmap转化为byte数组:
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
byte[] array= out.toByteArray();
将byte数组转化为Bitmap
final ContentResolver contentResolver = context.getContentResolver();
final PackageManager manager = context.getPackageManager();
final Cursor c = contentResolver.query(uri, null, null, null, null);
final int icon3DIndex = c.getColumnIndexOrThrow(ColumnName);
byte[] data = c.getBlob(icon3DIndex);
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
将Bitmap转化为Drawable:
Bitmap bitmap = new Bitmap(...);
Drawable drawable = new BitmapDrawable(bitmap);
//Drawable drawable = new FastBitmapDrawable(bitmap);
将Drawable转化为Bitmap:
Canvas canvas = new Canvas(bitmap)
drawable.draw(canvas);
Drawable d = ImagesList.get(0); Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
by: 发表于:2018-01-10 11:16:21 顶(0) | 踩(0) 回复
??
回复评论