因为公司项目需要,有一个群组聊天,头像显示是三个或者四个用户的头像的拼接,可能是品字型也可能是田字型。
自己想了一下,简单实现了一下,求大神们指教。谢谢
代码:
/** 横向连接两张图片 **/
public static Bitmap addHorizontalBitmap(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);
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStrokeWidth(20);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(first, 0, 0, null);
canvas.drawLine(first.getWidth(), 0, first.getWidth(),
first.getHeight(), paint);
canvas.drawBitmap(second, first.getWidth(), 0, null);
return result;
}
/** 纵向连接两张图片 **/
public