Byte[]转Bitmap
BitmapFactory.decodeByteArray(data, 0, data.length);
Bitmap转Byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); data2 = baos.toByteArray();
可以选择图片格式,这里是JPEG,可以用PNG
Bitmap转Drawable
Bitmap bm=xxx; //xxx根据你的情况获取 BitmapDrawable bd=BitmapDrawable(bm);
Drawable转Bitmap
Drawable d=xxx; //xxx根据自己的情况获取drawable BitmapDrawable bd = (BitmapDrawable) d; Bitmap bm = bd.getBitmap();
参考自:
http://blog.csdn.net/yelbosh/article/details/7916988
时间: 2024-10-14 03:15:18