转自:http://bingtian.iteye.com/blog/642128
从view中获得imageview 获得drawable
ImageView iv=(ImageView) view.findViewById(R.id.la_image); Drawable drawable=iv.getDrawable();
ava.lang.Object ↳ android.graphics.drawable.Drawable ↳ android.graphics.drawable.BitmapDrawable
drawable 转 bitmap
BitmapDrawable bd=(BitmapDrawable) drawable; Bitmap bm=bd.getBitmap();
bitma转成byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] by=baos.toByteArray();
byte[] 转成bitmap
Bitmap bm=BitmapFactory.decodeByteArray(b, 0, b.length)
bitmap 转成drawable
Drawable drawable = new BitmapDrawable(bitmap);