因此,我在android的SD卡上本地存储了两张图像,我想将它们组合成一张图像。这很难解释,所以我将链接到一张图片,以获得一个更好的例子,说明我如何拍摄前两张图片,并将它们组合到最后一张图片中。

发布于 2011-03-31 09:32:57
创建你的目标Bitmap,为它创建一个Canvas,使用Canvas.drawBitmap将每个源位图插入到你的目标位图中。
发布于 2012-04-10 01:50:58
我通常使用下面的函数from Jon Simon来组合两个作为参数传递的位图,并获得组合的位图作为输出。
public Bitmap combineImages(Bitmap c, Bitmap s)
{
Bitmap cs = null;
int width, height = 0;
if(c.getWidth() > s.getWidth()) {
width = c.getWidth() + s.getWidth();
height = c.getHeight();
} else {
width = s.getWidth() + s.getWidth();
height = c.getHeight();
}
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth(), 0f, null);
return cs;
} 发布于 2011-03-31 11:28:16
最简单的方法可能是在一个RelativeLayout中使用两个ImageViews。您可以在布局中将ImageViews放置在彼此的顶部。
https://stackoverflow.com/questions/5494342
复制相似问题