Example usage for android.graphics.drawable BitmapDrawable BitmapDrawable

List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable BitmapDrawable BitmapDrawable.

Prototype

@Deprecated
public BitmapDrawable(java.io.InputStream is) 

Source Link

Document

Create a drawable by decoding a bitmap from the given input stream.

Usage

From source file:Main.java

public static Drawable Bitmap2Drawable(Bitmap bitmap) {
    if (bitmap == null)
        return null;

    Drawable drawable = new BitmapDrawable(bitmap);

    return drawable;
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Drawable convertBitmap2Drawable(Bitmap bitmap) {
    if (null == bitmap)
        return null;
    BitmapDrawable bd = new BitmapDrawable(bitmap);
    return bd;//from ww  w.j a  v a 2  s  . c  o  m
}

From source file:Main.java

/**
 * @Description bitmap - > drawable// w  w  w .  j a va2 s .c  om
 * @param bitmap
 * @return
 */
public static Drawable Bitmap2Drawable(Bitmap bitmap) {
    BitmapDrawable bDrawable = new BitmapDrawable(bitmap);
    return bDrawable;
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static Drawable bitmap2Drawable(Bitmap bm) {
    if (bm == null) {
        return null;
    }/*  w w  w .j a  v a2s .c o m*/
    BitmapDrawable bd = new BitmapDrawable(bm);
    bd.setTargetDensity(bm.getDensity());
    return new BitmapDrawable(bm);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Drawable bitmap2Drawable(Bitmap bitmap) {
    if (bitmap == null) {
        return null;
    } else {//from ww w.  jav a2 s. c  o m
        return new BitmapDrawable(bitmap);
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Drawable getBitmapToDrawable(Bitmap bitmap) {
    BitmapDrawable bitmapDrawable = null;
    if (bitmap != null) {
        bitmapDrawable = new BitmapDrawable(bitmap);
    }/*  w  w  w.java  2  s  .  c  o  m*/
    return bitmapDrawable;
}

From source file:Main.java

@SuppressWarnings("deprecation")
private static Drawable bitmap2Drawable(Bitmap bm) {
    if (bm == null) {
        return null;
    }/*  ww w . j  a  v a 2  s . com*/
    return new BitmapDrawable(bm);
}

From source file:Main.java

public static StateListDrawable bgColorDrawableSelector(Bitmap nomal, Bitmap focus) {

    @SuppressWarnings("deprecation")
    BitmapDrawable nomalBitmap = new BitmapDrawable(nomal);
    @SuppressWarnings("deprecation")
    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 }, focusBitmap);
    selector.addState(new int[] {}, nomalBitmap);
    return selector;
}

From source file:Main.java

/**
 * convert Bitmap to Drawable// w  w w.  j  av a2s. c  o m
 * @param bitmap
 * @return
 */
public static Drawable bitmapToDrawable(Bitmap bitmap) {
    return bitmap == null ? null : new BitmapDrawable(bitmap);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static Drawable getConvertDrawable(String filepath) {
    Bitmap bitmap = BitmapFactory.decodeFile(filepath);
    Drawable drawable = new BitmapDrawable(bitmap);
    return drawable;
}