在android中合并两个图像的代码有问题吗?

在android中合并两个图像的代码有问题吗?,android,image-processing,Android,Image Processing,我使用下面的代码来组合两个图像 Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me); Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.static); Canvas comboImage = new Canvas(map); Bitmap out1 = null ; comb

我使用下面的代码来组合两个图像

    Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me);
    Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.static);
    Canvas comboImage = new Canvas(map);
    Bitmap out1 = null ;
    comboImage.setBitmap(out1);
    comboImage.drawBitmap(pic, 600, 350, null);

我假设我可以使用位图out1获得最终图像。但是“comboImage.setBitmap(out1);”线路发生故障。没有这条线,我看不到任何图像。如何获得最终的组合图像?

如果您希望最终图像为
out1
,您可以这样做:

Bitmap out1 = Bitmap.createBitmap(...);
Canvas comboImage = new Canvas(out1);
comboImage.drawBitmap(map, ...);
comboImage.drawBitmap(pic, ...);

out1
将成为合并图像

谢谢Matt。但如果我在“imView.setImageBitmap(out1);”的末尾再添加一行,应用程序就会崩溃。我遗漏了什么吗?或者我怎样才能保存位图out1?现在已经解决了。我错过了“imgView=(ImageView)findViewById(R.id.ImageView01);”谢谢Matt。