Convert drawable by id To Bitmap - Android Graphics

Android examples for Graphics:Drawable

Description

Convert drawable by id To Bitmap

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

public class Main {
    public static Bitmap drawableToBitmap(int drawable, Context context) {
        Bitmap output = null;//  w w w. j  a  v  a 2s .co  m
        output = BitmapFactory.decodeResource(context.getResources(),
                drawable);
        return output;
    }
}

Related Tutorials