CanvasView
CanvasView copied to clipboard
Eraser Mode
Hi, Eraser is not done correctly what actually does is just paint with a white color.
I resolve this problem by the following code.
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
paint.setARGB(0, 0, 0, 0);
Below code didn't work for eraser. paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); paint.setARGB(0, 0, 0, 0);
O'sum library,just a small problem same as above.Unable to use erase option using MainActivity.this.canvas.setMode(CanvasView.Mode.ERASER); It just draw the line.Kindly give me vision on how i can erase my previous drawing.I'm in hurry.
In case anyone else is having this problem, a quick fix in my case was calling setAlpha(0.99f)
on either your CanvasView object or a view containing it. It's not ideal, since the drawing is no longer fully opaque, but it allows your erase path to be transparent.
@kthilt can you share the code snippet of your solution? Actually I don't understand where you set alpha to 0.99f.
@jackmiras I'm setting the alpha for the instance of CanvasView I'm using. For example, in your activity onCreate(), you could do,
CanvasView myCanvasView = (CanvasView)findViewById(R.id.my_canvas_view_id); myCanvasView.setAlpha(0.99f);
Hey guys I've fixed the problem with erase mode... Check out my pull request or my fork of the project to see how the problem was solved and fix your code if you need.
@jackmiras , I am having still Eraser issue, canvas getting draw instead of erase. I hope that you can help me for the erasing thing. Rest of it works fine for me.
@hpdeveloper28 Have you checked my pull request? If not, this is the link to the file that I have changed in the fork that I made from Korilakkuma/CanvasView.
@jackmiras , thanks a lot, it worked for me. Appreciated.
@jackmiras , I have one more issue, when I set Background image for CanvasView and I try to erase then Background image getting clear, pleae let me know if you have any solution for the same.
Hi @hpdeveloper28 I doesn't face this problem because I don't work this much with the project. But I remember that everything that you draw will be put in the same canvas and one of the things that I hoped to implement in the future is put the draw in a new layer in order to have things in different layers.
hi @jackmiras, I am still not able to erase anything on canvas image, it's drawing eraser with a white background which is not useful while erasing anything on Image. Please suggest me what I need to do to erase draw things on an image?
@hpdeveloper28 Have you checked my pull request? If not, this is the link to the file that I have changed in the fork that I made from Korilakkuma/CanvasView.
Hello @jackmiras your link it is not work