Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.res.Resources;
import android.graphics.Bitmap;

import android.graphics.Canvas;

import android.graphics.drawable.Drawable;

public class Main {
    private static Bitmap drawToBitmap(Resources resources, int drawableResourceID, Bitmap bitmap) {
        Drawable drawable = resources.getDrawable(drawableResourceID);
        drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        drawable.draw(new Canvas(bitmap));
        return bitmap;
    }

    private static Bitmap drawToBitmap(Resources resources, int drawableResourceID, int size) {
        return drawToBitmap(resources, drawableResourceID, size, size);
    }

    private static Bitmap drawToBitmap(Resources resources, int drawableResourceID, int width, int height) {
        return drawToBitmap(resources, drawableResourceID,
                Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888));
    }
}