get Drawable To Bitmap - Android Graphics

Android examples for Graphics:Drawable

Description

get Drawable To Bitmap

Demo Code


//package com.java2s;

import android.content.Context;

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;

public class Main {
    public static Bitmap getDrawableToBitmap(int res_id, Context context) {
        BitmapDrawable drawable = (BitmapDrawable) context.getResources()
                .getDrawable(res_id);/*from   w ww  .  jav  a 2 s  . com*/
        Bitmap bitmap = drawable.getBitmap();

        return bitmap;
    }
}

Related Tutorials