add White Border to Bitmap - Android Graphics

Android examples for Graphics:Bitmap Effect

Description

add White Border to Bitmap

Demo Code


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

import android.graphics.Canvas;
import android.graphics.Color;

public class Main {
    public static Bitmap addWhiteBorder(Bitmap bmp, int borderSize) {
        Bitmap bmpWithBorder = Bitmap.createBitmap(bmp.getWidth()
                + borderSize * 2, bmp.getHeight() + borderSize * 2,
                bmp.getConfig());/*from  w w  w  .j a v a  2s.c  o m*/
        Canvas canvas = new Canvas(bmpWithBorder);
        canvas.drawColor(Color.WHITE);
        canvas.drawBitmap(bmp, borderSize, borderSize, null);
        return bmpWithBorder;
    }
}

Related Tutorials