Drawable轉bitmap
Drawable oDrawable = xxx; //xxx根據自己的情況獲取drawable
BitmapDrawable BD = (BitmapDrawable) oDrawable;
Bitmap BM = BD.getBitmap();
Bitmap轉byte陣列
Bitmap newbm;
// 把 bitmap 轉成 byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
newbm.compress(Bitmap.CompressFormat.JPEG, 100, stream );
byte bytes[] = stream.toByteArray();
byte陣列轉Bitmap
Bitmap geticon
byte[] data
geticon = BitmapFactory.decodeByteArray(data, 0, len);
Bitmap轉Drawable
Drawable showicon = new BitmapDrawable(geticon);
沒有留言:
張貼留言