Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; public class Main { private static Bitmap toBitmap(Drawable drawable, int width, int height) { Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas c = new Canvas(bmp); drawable.setBounds(new Rect(0, 0, width, height)); drawable.draw(c); return bmp; } }