我需要将多个图像组合成一个位图。我需要组合在2-6范围内的图像。图像的路径取自我的应用程序数据库,图像存储在我的外部SD卡中。我已经合并了2张图片。但我需要组合3,4,5和6个图像到单一画布。
我的两张图片的合并代码如下:
private Bitmap combineImageIntoOne(ArrayList<Bitmap> a) {
int top = 0;
int width = 0, height = 0;
for (int j = 0; j < a.size(); j++) {
width += a.get(j).getWidth();
}
height = a.get(0).getHeight();
Bitmap combineBitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(combineBitmap);
for (int i = 0; i < a.size(); i++) {
System.out.println("image width = " + top);
comboImage.drawBitmap(a.get(i), top, 0f, null);
top = top + a.get(i).getWidth();
}
System.out.println("combineBitmap combineBitmap..in.."+combineBitmap);
return combineBitmap;
}发布于 2014-05-28 14:24:50
我认为你可以用同样的代码把3,4,5和6张图片组合到一张画布上。
如果你想使用最高的位图的高度,你可以像这样修改代码。
//get the max height
height = a.get(0).getHeight();
for (int j = 0; j < a.size(); j++) {
width += a.get(j).getWidth();
if(height<a.get(j).getHeight()){
height=a.get(j).getHeight();
}
}https://stackoverflow.com/questions/23903863
复制相似问题