Android Utililty Methods Bitmap to Drawable Convert

List of utility methods to do Bitmap to Drawable Convert

Description

The list of methods to do Bitmap to Drawable Convert are organized into topic(s).

Method

Drawablebitmap2Drawable(Bitmap bitmap)
bitmap Drawable
Drawable drawable = new BitmapDrawable(bitmap);
return drawable;
Drawablefrom(Bitmap bitmap)
from
BitmapDrawable bitDrawable = new BitmapDrawable(bitmap);
return bitDrawable;
DrawableBitmapToDrawable(final Bitmap bitmap)
Bitmap To Drawable
BitmapDrawable bd = new BitmapDrawable(bitmap);
return bd;
DrawablebitmapToDrawable(Bitmap bitmap)
bitmap To Drawable
BitmapDrawable mBitmapDrawable = null;
try {
    if (bitmap == null) {
        return null;
    mBitmapDrawable = new BitmapDrawable(bitmap);
} catch (Exception e) {
    e.printStackTrace();
...
TransitionDrawablebitmapToTransitionDrawable( Bitmap bitmap)
bitmap To Transition Drawable
TransitionDrawable mBitmapDrawable = null;
try {
    if (bitmap == null) {
        return null;
    mBitmapDrawable = new TransitionDrawable(new Drawable[] {
            new ColorDrawable(android.R.color.transparent),
            new BitmapDrawable(bitmap) });
...
DrawablegeRoundDrawableFromUrl(String url, int pixels)
ge Round Drawable From Url
byte[] bytes = getBytesFromUrl(url);
BitmapDrawable bitmapDrawable = (BitmapDrawable) byteToDrawable(bytes);
return toRoundCorner(bitmapDrawable, pixels);
StateListDrawablebgColorDrawableSelector(Bitmap nomal, Bitmap focus)
bg Color Drawable Selector
BitmapDrawable nomalBitmap = new BitmapDrawable(nomal);
BitmapDrawable focusBitmap = new BitmapDrawable(focus);
StateListDrawable selector = new StateListDrawable();
selector.addState(new int[] { android.R.attr.state_pressed },
        focusBitmap);
selector.addState(new int[] { android.R.attr.state_selected },
        focusBitmap);
selector.addState(new int[] { android.R.attr.state_focused },
...
DrawablebitmapToDrawable(Bitmap bitmap)
bitmap To Drawable
BitmapDrawable mBitmapDrawable = null;
try {
    if (bitmap == null) {
        return null;
    mBitmapDrawable = new BitmapDrawable(bitmap);
} catch (Exception e) {
    e.printStackTrace();
...
TransitionDrawablebitmapToTransitionDrawable( Bitmap bitmap)
bitmap To Transition Drawable
TransitionDrawable mBitmapDrawable = null;
try {
    if (bitmap == null) {
        return null;
    mBitmapDrawable = new TransitionDrawable(new Drawable[] {
            new ColorDrawable(android.R.color.transparent),
            new BitmapDrawable(bitmap) });
...