Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; public class Main { public static final int LEFT = 0; public static final int RIGHT = 1; public static final int TOP = 3; public static final int BOTTOM = 4; public static Bitmap potoMix(int direction, Bitmap... bitmaps) { if (bitmaps.length <= 0) { return null; } if (bitmaps.length == 1) { return bitmaps[0]; } Bitmap newBitmap = bitmaps[0]; // newBitmap = createBitmapForFotoMix(bitmaps[0],bitmaps[1],direction); for (int i = 1; i < bitmaps.length; i++) { newBitmap = createBitmapForFotoMix(newBitmap, bitmaps[i], direction); } return newBitmap; } private static Bitmap createBitmapForFotoMix(Bitmap first, Bitmap second, int direction) { if (first == null) { return null; } if (second == null) { return first; } int fw = first.getWidth(); int fh = first.getHeight(); int sw = second.getWidth(); int sh = second.getHeight(); Bitmap newBitmap = null; if (direction == LEFT) { newBitmap = Bitmap.createBitmap(fw + sw, fh > sh ? fh : sh, Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawBitmap(first, sw, 0, null); canvas.drawBitmap(second, 0, 0, null); } else if (direction == RIGHT) { newBitmap = Bitmap.createBitmap(fw + sw, fh > sh ? fh : sh, Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawBitmap(first, 0, 0, null); canvas.drawBitmap(second, fw, 0, null); } else if (direction == TOP) { newBitmap = Bitmap.createBitmap(sw > fw ? sw : fw, fh + sh, Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawBitmap(first, 0, sh, null); canvas.drawBitmap(second, 0, 0, null); } else if (direction == BOTTOM) { newBitmap = Bitmap.createBitmap(sw > fw ? sw : fw, fh + sh, Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); canvas.drawBitmap(first, 0, 0, null); canvas.drawBitmap(second, 0, fh, null); } return newBitmap; } }