android拼接多张bitmap图片


/**
* 横向拼接
* <功能详细描述>
* @param first
* @param second
* @return 
*/
private Bitmap add2Bitmap(Bitmap first, Bitmap second) {
int width = first.getWidth() + second.getWidth();
int height = Math.max(first.getHeight(), second.getHeight());
Bitmap result = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(first, 0, 0, null);
canvas.drawBitmap(second, first.getWidth(), 0, null);
return result;

}


/**
* 纵向拼接
* <功能详细描述>
* @param first
* @param second
* @return 
*/
private Bitmap addBitmap(Bitmap first, Bitmap second) {
int width = Math.max(first.getWidth(),second.getWidth());
int height = first.getHeight() + second.getHeight();
Bitmap result = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(first, 0, 0, null);
canvas.drawBitmap(second, first.getHeight(), 0, null);
return result;
}

你可能感兴趣的:(android,bitmap,图片)