Java tutorial
//package com.java2s; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; public class Main { /** * @deprecated Use {@link #getDrawable(byte[], Resources)} to ensure * that the drawable has correctly set its target density. */ public static Drawable getDrawable(byte[] byteArray) { return byteArray == null ? null : getDrawable(getBitmap(byteArray)); } public static Drawable getDrawable(byte[] byteArray, Resources resources) { return byteArray == null ? null : getDrawable(getBitmap(byteArray), resources); } /** * @deprecated Use {@link #getDrawable(Bitmap, Resources)} to ensure * that the drawable has correctly set its target density. */ public static Drawable getDrawable(Bitmap bitmap) { return bitmap == null ? null : new BitmapDrawable(bitmap); } public static Drawable getDrawable(Bitmap bitmap, Resources resources) { return bitmap == null ? null : new BitmapDrawable(resources, bitmap); } public static Bitmap getBitmap(byte[] byteArray) { return byteArray == null ? null : BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); } public static Bitmap getBitmap(Drawable drawable) { return drawable == null ? null : ((BitmapDrawable) drawable).getBitmap(); } }