Android Drawable to Bitmap Convert drawableToBitmap(Drawable drawable, int width, int height)

Here you can find the source of drawableToBitmap(Drawable drawable, int width, int height)

Description

drawable To Bitmap

Declaration

public static Bitmap drawableToBitmap(Drawable drawable, int width,
            int height) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Canvas;

import android.graphics.drawable.Drawable;

public class Main {
    public static Bitmap drawableToBitmap(Drawable drawable, int width,
            int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height,
                Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(bitmap);

        // canvas.setBitmap(bitmap);

        drawable.setBounds(0, (int) (height / 2.0), width, height);

        drawable.draw(canvas);/*from   www  .j a v  a 2  s  .  co m*/

        return bitmap;

    }
}

Related

  1. DrawableToBitmap(Drawable drawable)
  2. convertDrawableToBitmap(Drawable drawable)
  3. drawable2Bitmap(Drawable drawable)
  4. drawableToBitmap(Drawable drawable)
  5. getBitmap(Resources resources, int drawableResourceId)
  6. getBitmapDrawable(Context context, int resId)
  7. from(Drawable drawable)
  8. drawableToBitmap(Drawable drawable)