Java tutorial
//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.Matrix; public class Main { public static Bitmap drawImageBorder(Bitmap srcBitmap, Bitmap borderBitmap) { if (srcBitmap == null) throw new NullPointerException("srcBitmap should not null"); if (borderBitmap == null) return srcBitmap; Bitmap temp = srcBitmap.copy(Config.ARGB_8888, true); /*Bitmap border = borderBitmap; if (srcBitmap.getWidth() != borderBitmap.getWidth() || srcBitmap.getHeight() != borderBitmap.getHeight()) { border = zoomBitmap(borderBitmap, srcBitmap.getWidth(), srcBitmap.getHeight()); }*/ Canvas canvas = new Canvas(temp); Matrix m = new Matrix(); m.postScale((float) temp.getWidth() / borderBitmap.getWidth(), (float) temp.getHeight() / borderBitmap.getHeight()); //canvas.drawBitmap(border, 0, 0, null); canvas.drawBitmap(borderBitmap, m, null); return temp; } }