Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; public class Main { public static Bitmap joinBitmaps(Bitmap first, Bitmap second) { Bitmap result = Bitmap.createBitmap(first.getWidth(), first.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); Paint bitmapPaint = new Paint(); if (second.getWidth() != first.getWidth() && second.getHeight() != first.getHeight()) { second = createScaledToFillBitmap(second, first.getWidth(), first.getHeight()); } canvas.drawBitmap(first, 0, 0, bitmapPaint); canvas.drawBitmap(second, 0, 0, bitmapPaint); return result; } public static Bitmap createScaledToFillBitmap(Bitmap bitmap, int reqWidth, int reqHeight) { final int height = bitmap.getHeight(); final int width = bitmap.getWidth(); float widthScaleF = (float) width / (float) reqWidth; float heightScaleF = (float) height / (float) reqHeight; if (widthScaleF < heightScaleF) { return Bitmap.createScaledBitmap(bitmap, reqWidth, (int) (height / widthScaleF), true); } else { return Bitmap.createScaledBitmap(bitmap, (int) (width / heightScaleF), reqHeight, true); } } }