Convert Drawable to Bitmap to Drawable

Context context = getApplicationContext();
Drawable drawable = context.getResources().getDrawable(R.drawable.my_image);
// convert drawable to bitmap
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
// convert bitmap to drawable
Drawable d = new BitmapDrawable(bitmap);

Android example source code.

This entry was posted in Android Examples Code, Bitmap, drawing and tagged , , . Bookmark the permalink.

Comments are closed.