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 8923291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:04:51+00:00 2026-06-15T07:04:51+00:00

Good morning, A portion of my apps features the ability to write down some

  • 0

Good morning,

A portion of my apps features the ability to write down some hand written notes. I am using pieces from the fingerpaint example to implement the “eraser” in my app:

mPaint.setXfermode(new PorterDuffXfermode(
        PorterDuff.Mode.CLEAR));
mPaint.setStrokeWidth(45);
mPaint.setStrokeCap(Paint.Cap.ROUND);

The problem is whenever I erase there is a black path where the user has erased. It is gone once the user picks up their finger, but it is there while they are erasing. My friend tells me that PorterDuff modes are not supposed to be used in real time, but I don’t believe him. Here’s some more of my code just in case I did something dumb:

mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(false);
mPaint.setColor(Color.BLACK);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.BUTT);
mPaint.setStrokeWidth(6);
mBitmap = Bitmap.createBitmap(800, 480,Bitmap.Config.ARGB_8888);
bBitmap = Bitmap.createBitmap(800, 480,Bitmap.Config.ARGB_8888);
bBitmap.eraseColor(Color.WHITE);
mCanvas = new Canvas(mBitmap);
mPath = new Path();
mBitmapPaint = new Paint();
maxX = maxY = 100;
minX = 750;
minY = 400;

//

private void touch_up() {
    mPath.lineTo(mX, mY);
    mCanvas.drawPath(mPath, mPaint);
    mPath.reset();
}

//

protected void onDraw(Canvas canvas) {    
    canvas.drawBitmap(bBitmap, 0, 0, null);
    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    canvas.drawPath(mPath, mPaint);
}

Is it possible to do what I want this eraser to do? Is there a better way to do this? Is my friend actually right?

Also I tried just painting white as an erase but it’s not going to work because sometimes there is an image underneath that the user is marking up. I could go through and make every white pixel transparent, but that seems super inefficient.

  • 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-15T07:04:52+00:00Added an answer on June 15, 2026 at 7:04 am

    Ok so I figured out a solution. I’ll leave this here for people running into a similar problem:

    case MotionEvent.ACTION_DOWN:
    mPaint.setStrokeWidth(25);
                mPaint.setXfermode(new PorterDuffXfermode(
                        PorterDuff.Mode.CLEAR));
                mCanvas.drawCircle(x, y, 10, mPaint);
                isErase = true;
                invalidate();
            }
            touch_start(x, y);
            invalidate();
            break;
    case MotionEvent.ACTION_MOVE:   
            if(isErase)
            {
                mCanvas.drawCircle(x, y, 20, mPaint);
            }
            else{
                touch_move(x, y);
            }invalidate();
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning, I am in need of some advice, I am using a networkStream,
Good morning. I've been having this issue for some days and have been lokking
Good morning gang. I have a jQuery Datepicker object that is prepoulated using a
Good morning ! What is the best way to remove duplicate records from grid
Good Morning, i have some Trouble with the Zend Framework and Zend_DB_Select, i want
Good morning! I'm programming a managment aplication that shows a task list using WPF
Good Morning, I am developing a four column footer using pure CSS, but I
Good morning! Is possible or had some plugin to change color in the email
Good morning, I have to use the properties from DeviceNetworkInformation in my application. (http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=vs.92).aspx)
Good morning!! I have a dynamic datatable and I'm using Columns of Richfaces, but

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.