Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; public class Main { public static Bitmap toBitmap(Drawable drawable) { BitmapDrawable bd = (BitmapDrawable) drawable; Bitmap bm = bd.getBitmap(); return bm; } public static Bitmap toBitmap(byte[] data) { return BitmapFactory.decodeByteArray(data, 0, data.length); } }