I want to fill the specific part of the image with certain color.
In my case I want to fill the A part with green color.
But when I am using canvas in android. It is going to draw color in the area where A is not there
Related
I am creating a simple drawing app using kotlin. I want to implement an eraser and was not able to find any proper solution for this. Every solution either uses white color as a substitute for eraser or completely resets the canvas after clicking on eraser button. As I have also implemented the feature of importing background images from the gallery, I can't use white color as eraser.
There is no magic eraser in canvas, because erasing is nothing but drawing something onto the canvas. You can't set the paint color to Transparent and draw on canvas to erase what is already drawn. This simply draws something that is transparent, which is basically nothing.
So you will need to implement an eraser by using a Color. Normally this is white, because the background is usually set to white. So this gives the appearance of erasing the content.
In your case, you have a background image. To implement an eraser for this, you will need 2 canvas. The background image will be drawn in the 1st canvas. All the other content (drawCircle, drawRect, drawPath, etc...) are drawn onto the 2nd canvas. Now, you could take the bitmap out of the 2nd canvas and draw that in the 1st canvas (drawBitmap). This gives the final appearance.
Now, in this setup, you could use "White" as a color to erase from the 2nd canvas. While drawing 2nd canvas content onto the 1st, use one of the PorterDuff mode, so that the "White" goes away.
I am using drawing view to draw on touch of user , So I need to put the image in front of it. There are some letters written in the middle of image , which is in translucent , while the other places are covered with color. So on touch the user would only see the letter filling with paint as the letter is transparent and translucent.
Edited
is the picture, I want to fill the only white space with color on user touch. Right now I am painting on a white canvas and , truly I have copied the code of touch to draw from android api demo folder. So please Tell me How to fill that white blank space only .
I came up with idea and that is to draw canvas as the source code of api demo is doing , and just put the imageveiw in front of this canvas hence user would only see the white area is filling with color. Any idea that How can I perform this ?
So My major problem is how to put that image view in front canvas in android. ?
I need to create the painting application for the kids where kid can colour inside the black bordered sketch of any image
But, I am struck with the problem,that colouring can come outside the black bordering of the image...which i don't want to.Please guys help me to find out how to restrict the colouring by user within the black border of sketch
Also, I want that no colour should cover the black border.it should be inside the border.
I can post my code if required.
Look at Canvas clipPath and use the clipping built in to android to limit the 'coloring' of the kid/user to the regions you specify. You can then draw your objects as layers, kid/user colored layer on bottom, your sketch on top.
Finally..i have implemented it using mask bitmap and right usage of Portet.Duff mode
Fellow Programmers,
I am new to android and I am trying to draw on a image based on giving the x and y axis of the image as the input.So that he pixel value corresponding to the coordinate gets filled with a color that I mention. Say Red color for now.
User Story: Render a image through image view and on a button click I need to pass the co-ordinate value for the image that represents the pixel of the image and fill it with red color. Keep on doing it looks like drawing on the image that I render using image view.
Is this user story is possible to do in Android? If then help me on this. I referred the draw class and canvas class and not sure how to implement.
Looking forward to ur help on developing this user story on android application.
Best,
Googler
Take a blank canvas.
Draw your image on the canvas.
Draw points on the canvas by specifying x and y co-ordinates and red color in paint.
This is my first post.
I'm developing a drawing application for Android and are opposite to a problem that I can not fix.
I have an image with various geometric shapes also superimposed. Each has a different colored geometric shapes.
With Avoidxfermode I can draw on the form with a specific color.
Now I would like the colorful picture is not visible to the user.
In practice I would recognize the area in which color through the colored picture, but I would like the new color to appear on a white image