Here you can find the source of merge(Bitmap bmp1, Bitmap bmp2)
public static final Bitmap merge(Bitmap bmp1, Bitmap bmp2)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; public class Main { public static final Bitmap merge(Bitmap bmp1, Bitmap bmp2) { if (null == bmp1 || bmp1.isRecycled() || null == bmp2 || bmp2.isRecycled())//from w w w. ja v a2 s. c o m return null; Paint paint_comm = new Paint(Paint.ANTI_ALIAS_FLAG); Bitmap bmOverlay = Bitmap.createBitmap(bmp2.getWidth(), bmp2.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmOverlay); float x = (bmp2.getWidth() - bmp1.getWidth()) / 2f; float y = (bmp2.getHeight() - bmp1.getHeight()) / 2f; x = x > 0 ? x : 0; y = y > 0 ? y : 0; canvas.drawBitmap(bmp1, x, y, paint_comm); canvas.drawBitmap(bmp2, 0, 0, paint_comm); return bmOverlay; } }