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

private BitmapDrawable(BitmapState state, Resources res) 

Source Link

Usage

From source file:Main.java

/**
 * bitmap to drawable//from   w  ww.  ja  v a  2s  . c  om
 * @param res
 * @param bitmap
 * @return
 */
public static Drawable bitmapToDrawable(Resources res, Bitmap bitmap) {
    Drawable drawable = new BitmapDrawable(res, bitmap);
    return drawable;
}

From source file:Main.java

public static Drawable resizeToIcon(final Bitmap bitmap, final int width, final int height) {
    final Bitmap b = Bitmap.createScaledBitmap(bitmap, width, height, true);
    final Drawable d = new BitmapDrawable(Resources.getSystem(), b);
    return d;// w ww  .j  a v a 2  s .  c  o  m
}

From source file:Main.java

/**
 * Bitmap to Drawable/*  w  w w  . j  a  v a 2s  .  c om*/
 *
 * @param bitmap
 * @param mcontext
 * @return
 */
public static Drawable bitmapToDrawble(Bitmap bitmap, Context mcontext) {
    Drawable drawable = new BitmapDrawable(mcontext.getResources(), bitmap);
    return drawable;
}

From source file:Main.java

public static Drawable getRotateDrawable(Resources res, final Bitmap bitmap, final float angle) {
    final BitmapDrawable drawable = new BitmapDrawable(res, bitmap) {
        @Override//from   www  .  ja v a  2s.  c o  m
        public void draw(final Canvas canvas) {
            canvas.save();
            canvas.rotate(angle, bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            super.draw(canvas);
            canvas.restore();
        }
    };
    return drawable;
}

From source file:Main.java

public static Drawable bitmap2drawable(Resources res, Bitmap bitmap) {
    if (res == null || bitmap == null) {
        return null;
    }//ww w.  java2 s  .c om
    BitmapDrawable bd = new BitmapDrawable(res, bitmap);
    return bd;
}

From source file:Main.java

public static Drawable resizeDrawable(Context context, Drawable drawable, int width, int height) {
    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
    Drawable newDrawable = new BitmapDrawable(context.getResources(),
            Bitmap.createScaledBitmap(bitmap, width, height, true));

    return newDrawable;
}

From source file:Main.java

public static Drawable bitmap2Drawable(Resources res, Bitmap bitmap) {
    return new BitmapDrawable(res, bitmap);
}

From source file:Main.java

public static Drawable bitmapToDrawable(Context context, Bitmap bitmap) {
    if (context == null || bitmap == null) {
        throw new IllegalArgumentException("Params illegal, please check you param");
    }/*from   w  ww. jav  a 2s .c  om*/
    Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
    return drawable;
}

From source file:Main.java

public static Drawable getBitmapDrawable(Context ctx, int value) {
    Bitmap bmp = BitmapFactory.decodeResource(ctx.getResources(), value);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(ctx.getResources(), bmp);
    bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
    return bitmapDrawable;
}

From source file:Main.java

public static Drawable getIcon(Context context, byte[] rawData) {
    if (rawData == null) {
        return null;
    }//from w  ww  .j  a  va 2 s.  co m
    Bitmap bmp = BitmapFactory.decodeByteArray(rawData, 0, rawData.length);
    return new BitmapDrawable(context.getResources(), bmp);
}