Android examples for Graphics:Bitmap Combine
blend Middle Bitmap Image
//package com.java2s; import java.util.ArrayList; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Xfermode; public class Main { public static Bitmap blendMiddle(Bitmap src, Bitmap dst, int width, int height, Xfermode mode) { ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(); bitmaps.add(src);/* w w w. j av a 2s. c o m*/ bitmaps.add(dst); return blendMiddle(bitmaps, width, height, mode); } public static Bitmap blendMiddle(ArrayList<Bitmap> bitmaps, int width, int height, Xfermode mode) { Bitmap blendedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas myCanvas = new Canvas(blendedBitmap); Paint paint = new Paint(); paint.setXfermode(mode); final int length = bitmaps.size(); for (int i = 0; i < length; i++) { Bitmap bm = bitmaps.get(i); float left = ((float) (width - bm.getWidth())) / 2; float top = ((float) (height - bm.getHeight())) / 2; myCanvas.drawBitmap(bm, left, top, paint); } return blendedBitmap; } }