合成两张图片
通过canvas绘制合成
private Bitmap mergeBitmap(Bitmap firstBitmap, Bitmap secondBitmap) {
int w1 = firstBitmap.getWidth();
int h1 = firstBitmap.getHeight();
int w2 = secondBitmap.getWidth();
int h2 = secondBitmap.getHeight();
int space = 20;
Bitmap bitmap = Bitmap.createBitmap(w1, h1 + h2 + 40,
firstBitmap.getConfig());
Canvas canvas = new Canvas(bitmap);
canvas.drawRGB(255, 255, 255);
canvas.drawBitmap(firstBitmap, new Matrix(), null);
int left = w1 - w2 > 0 ? ((w1 - w2) / 2) : 0;
canvas.drawBitmap(secondBitmap, left, h1 + 20, null);
return bitmap;
}
代码很简单,代码是将两张图片上下衔接。