Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:10:44+00:00 2026-06-05T15:10:44+00:00

i am working on a android project for my assignment. i am trying to

  • 0

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

Here’s the appearance of my project:

layout

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:10:45+00:00Added an answer on June 5, 2026 at 3:10 pm

    Interesting question. My theoretical plan:

    You have 2 bitmaps, the ‘erasable’ bitmap and the ‘hidden’ bitmap. Erasing pixels from an existing bitmap is not possible because Bitmap’s in Android are immutable. So instead of erasing pixels from the ‘erasable’ bitmap to reveal the bitmap underneath, first draw the ‘erasable’ bitmap. Then create an empty, mutable Bitmap. Loop over all of the pixels in the ‘hidden’ bitmap, displaying only where the ‘erasable’ bitmap has been ‘erased’.

    Bitmap mutableBitmap = Bitmap.create(erasableBitmap.getWidth(),erasableBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    
    for(Pixel erasedPixel : erasedList)
    {
      mutableBitmap.setPixel(x,y, hiddenBitmap.getPixel(erasedPixel.x, erasedPixel.y));
    }
    
    ...
    // in a different file
    class Pixel{
      int x, y;
    
    }
    

    you’ll have to fill the erasedList yourself.

    Once you are done, draw to the canvas like so:

    canvas.drawBitmap(0,0,eraseableBitmap);
    canvas.drawBitmap(0,0,mutableBitmap);
    

    making sure that you draw the ‘erasable’ bitmap first so that it is drawn over with the new pixels.

    If you need help figuring out how to set the erased pixels, let me know in the comments and I’ll help you out.

    EDIT

    To actually figure out which pixels the user tried to erase: In your view, capture the onTouch event and you’ll get a coordinate of where the user touched the screen. Save that to a some sort of map or hashtable and you should be good to go. Create a Pixel object and add it to a global List of pixels.

    EDIT 2

    To increase the size of the “scratch” what you have to do is a little complicated. You need some way to create an area around the x,y point touched to also count as erased. A circle would be ideal but it will be easier to use a square.

    for(Pixel erasedPixel: erasedList)
    {
      //it's actually more complicated than this, since you need to check for boundary conditions.
      for(int i = -SQUARE_WIDTH/2; i < SQUARE_WIDTH/2; i++){
        for(int j = -SQUARE_WIDTH/2; j < SQUARE_WIDTH/2; j++){
          mutableBitmap.setPixel(erasedPixel.x+i, erasedPixel.y+j, hiddenBitmap.getPixel(erasedPixel.x+i, erasedPixel.y+j));
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an android project and I would like to create an
I'm working on an android project that involves native code and I'm trying to
I am currently working on an android project. I am trying to have an
I am working on my android project with SQLite database. I need to get
When I try to run my Android project(which was working fine yesterday) I get
Am working on android project. Its like filling form. And I can list number
When I'm working on Android project I would like to use some magic shortcut
I am working on android project. My requirement is to store image from android
I'm working on an Android project using API 7 and I'm trying to start
I am working on android project in which I have to apply loading screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.