使用代码把两个图像结合起来

我使用下面的代码把两个图像结合起来。

 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);

假定我可以使用 bitmap out1 获取最后的图像,但是 comboImage.setBitmap(out1); 这一行引发崩溃。没有这一行不能看到任何图像。如何获取最后结合图像?

Bitmap pic = BitmapFactory.decodeResource(getResources(), R.drawable.me);
Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.static);

 **Bitmap out1 = Bitmap.createBitmap(width, height, Config.ARGB_8888);;
Canvas comboImage = new Canvas(out1);
comboImage.drawBitmap(map, 0, 0, null);
comboImage.drawBitmap(pic, 600, 350, null);** 

你是要把两张叠加成一张图?如果是下面的是可行的。

Bitmap bitmap1 = ((BitmapDrawable) getResources().getDrawable( R.drawable.ic_default_slide)).getBitmap();
Bitmap bitmap2 = ((BitmapDrawable) getResources().getDrawable(   R.drawable.ic_slide_player)).getBitmap();

Drawable[] array = new Drawable[2];
array[0] = new BitmapDrawable(bitmap1);
array[1] = new BitmapDrawable(bitmap2);
LayerDrawable la = new LayerDrawable(array);
// 其中第一个参数为层的索引号,后面的四个参数分别为left、top、right和bottom
la.setLayerInset(0, 0, 0, 0, 0);
la.setLayerInset(1, 20, 20, 20, 20);
im.setImageDrawable(la);