Android How to set the imageview in front of drawingview - android

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. ?

Related

How to implement a real eraser in my drawing app?

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.

Fill Color in Specific Part of Image but with Touch only and not with FloodFill

I am making an Android app for colour book, where I have various images with different parts, and when user touch on it - it will be coloured.
I have seen so many answers here for this question but all of them uses Flood Fill algorithm. I don't want to fulfill that part with only one touch, I want the user should fill it with his touch, as a painter uses his brush.
I am using Canvas' onTouchEvent, OnDraw etc. methods for getting the touched area painted, but when user draw his finger outside specific part of image, that part also get colored (even the outer part of Image also gets colored when user touch the background).
I want the user can only paint the specific area of that image and that area will not be fullfilled by only one touch (as FloodFill does), it should be painted as a painter paints with his brush.
Can anybody give me some advice how I can implement what I want?

Draw on specific part of Image

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

canvas drawing issue where paint needs to be restricted by black sketch

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

Draw on imageview image in android?

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.

Categories

Resources