static final int PICKED_TWO = 1;
boolean onePicked = false;
boolean twoPicked = false;
Button choosePicture1, choosePicture2;
我們將有一個ImageView用于顯示最終的合成圖像。同時還需要有兩個位圖對象,為每幅選定的圖像使用一個該對象。
mageView compositeImageView;
Bitmap bmp1, bmp2;
與前面的示例一樣,將需要一個在其上繪制的Canvas對象和一個進行繪制的Paint對象。
Canvas canvas;
Paint paint;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
compositeImageView = (ImageView) this.findViewById(R.id.CompositeImageView);choosePicture1 = (Button) this.findViewById(R.id.ChoosePictureButton1);
choosePicture2 = (Button) this.findViewById(R.id.ChoosePictureButton2);
choosePicture1.setOnClickListener(this);
choosePicture2.setOnClickListener(this);
}