Scratch the screen to display an image in android
- by user1008497
i am working on a android project for my assignment. i am trying to make a scratch image application, you know it's like we scratch the screen to get rid the blocking layer to display the image. but the problem is i don't know where to start.
i have searching in stackoverflow's questions that related to this but that's not help.
from my search there, i found a clue for this project is using Bitmap.getPixel(int x, int y).
so, in my thought i have to get pixel from bitmap and paint it to canvas.
but i don't know how to implement it?
or anyone has a better method for this?
Could anyone please help me? Any tutorials on this kind of thing or related topics?
Thanks in advance!
here's my sample code:
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
tw = w;
th = h;
eraseableBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(eraseableBitmap);
Bitmap muteableBitmap = Bitmap.createBitmap(eraseableBitmap.getWidth(), eraseableBitmap.getHeight(), Bitmap.Config.ARGB_8888);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
static_x = event.getX();
static_y = event.getY();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
touch_start(static_x, static_y);
} if (event.getAction() == MotionEvent.ACTION_MOVE) {
touch_move(static_x, static_y);
} if (event.getAction() == MotionEvent.ACTION_UP) {
touch_up();
}
return true;
}