80,359
社区成员
发帖
与我相关
我的任务
分享
/**
* 拼接图片
* @param bitmaps 原图片的大小
* @return 拼接后的新图
*/
private Bitmap combineImage(Bitmap... bitmaps) {
int width = 0;
int height = 0;
//获取最大宽度
for (Bitmap bitmap : bitmaps) {
height = height + bitmap.getHeight();
if (width < bitmap.getWidth()) {
width = bitmap.getWidth();
}
}
Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
int tempHeight = 0;
//画图
for (int i = 0; i < bitmaps.length; i++) {
canvas.drawBitmap(bitmaps[i], 0, tempHeight, null);
tempHeight = bitmaps[i].getHeight() + tempHeight;
bitmaps[i].recycle();
}
return newBitmap;
}
private Bitmap combineImage(Bitmap... bitmaps) {
int width = 0;
int height = 0;
//获取最大宽度
for (Bitmap bitmap : bitmaps) {
height = height + bitmap.getHeight();
if (width < bitmap.getWidth()) {
width = bitmap.getWidth();
}
}
Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
int tempHeight = 0;
//画图
for (int i = 0; i < bitmaps.length; i++) {
canvas.drawBitmap(bitmaps[i], 0, tempHeight, null);
tempHeight = bitmaps[i].getHeight() + tempHeight;
bitmaps[i].recycle();
}
return newBitmap;
}