Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;

public class Main {
    public static Bitmap setupFrame(Bitmap bitmap, int width, int color) {
        if (bitmap.getWidth() <= width * 2 || bitmap.getHeight() <= width * 2) {
            return bitmap;
        }

        Bitmap bp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);

        Canvas canvas = new Canvas(bp);
        canvas.drawBitmap(bitmap, 0, 0, new Paint());
        Paint paint = new Paint();
        paint.setColor(color);
        paint.setStrokeWidth(width);
        paint.setStyle(Style.STROKE);
        canvas.drawRect(0, 0, canvas.getWidth() - width, canvas.getHeight() - width, paint);

        bitmap.recycle();
        return bp;
    }
}