Create Drawable from Bitmap - Android Graphics

Android examples for Graphics:Drawable

Description

Create Drawable from Bitmap

Demo Code


//package com.java2s;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable from(Bitmap bitmap) {
        BitmapDrawable bitDrawable = new BitmapDrawable(bitmap);
        return bitDrawable;
    }//www  .  ja  v  a2 s .co m

    public static Bitmap from(Drawable drawable) {
        BitmapDrawable bitDrawable = (BitmapDrawable) drawable;
        return bitDrawable.getBitmap();
    }
}

Related Tutorials