Android examples for Graphics:Drawable Byte Array
Convert byte array to Drawable
//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 Drawable bytes2Drawable(byte[] b) { Bitmap bitmap = bytes2Bitmap(b); return bitmap2Drawable(bitmap); }// ww w . ja v a 2 s. c o m public static Bitmap bytes2Bitmap(byte[] b) { if (b.length != 0) { return BitmapFactory.decodeByteArray(b, 0, b.length); } return null; } public static Drawable bitmap2Drawable(Bitmap bitmap) { @SuppressWarnings("deprecation") BitmapDrawable bd = new BitmapDrawable(bitmap); Drawable d = (Drawable) bd; return d; } }