AndroidでのBitmap,Drawable,Byte間の変換


1.  Bitmap     byte
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
byte[] array= out.toByteArray();

2. 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);

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);