i want to make an application in that there is two bitmap, i want to remove image whenever i touch my finger or move my finger and second bitmap's part be shown will be shown & first image's part will be erased i have used following code but in that both images are replacing but i want to erase only first one, second will shown on erased area, ..can any body help me how to handle this
below is the code
public class PaintView extends View implements OnTouchListener {
private static final String TAG = "PaintView";
Bitmap Bitmap1, Bitmap2;
Bitmap Transparent;
Bitmap overlay;
int X = -100;
int Y = -100;
Canvas c2;
// List<Point> points = new ArrayList<Point>();
Paint paint = new Paint();
public PaintView(Context context) {
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
this.setOnTouchListener(this);
Bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.bear);
Bitmap2 = BitmapFactory
.decodeResource(getResources(), R.drawable.camel);
Transparent = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
c2 = new Canvas();
c2.setBitmap(Transparent);
c2.drawBitmap(Bitmap1, 0, 0, null);
paint.setAlpha(0);
paint.setStyle(Style.FILL);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
paint.setAntiAlias(true);
}
@Override
public void onDraw(Canvas canvas) {
c2.drawBitmap(Bitmap2, 0, 0, null);
c2.drawCircle(X, Y, 50, paint);
canvas.drawBitmap(Transparent, 0, 0, null);
}
public boolean onTouch(View view, MotionEvent event) {
X = (int) event.getX();
Y = (int) event.getY();
invalidate();
return true;
}
}
class Point {
float x, y;
@Override
public String toString() {
return x + ", " + y;
}
}