I'm using an library called ImageTouchView to have pinch zooming feature in my application. But whenever I use Canvas to draw a line on it, the drawn line does not zoom in/out, it just stays with the same size.
How am I be able to also zooming the drawn line?
I have solved it. To do it, I had to get the Canvas draw (with all lines I want) and convert it to an bitmap. Then I set this bitmap to the ImageView bitmap. Works like a charm!
Related
I'm working on an APP in Android and needs to draw things on a Canvas. I want to draw a Path that is hollow, for example something like this image below.
View Image
The Path may contains lines, arcs, bezier curves, etc.
Is there a way for me to achieve that?
I had tried to draw the Path with a thicker Paint first and draw the Path again with a transparent and thinner Paint. But the problem is: there may be other things drawn on the Canvas. Doing so will cover other things intersecting with the Path.
I had also tried to translate the Canvas and draw the Path twice for the two borders. But it turned out that this will not work, for example a parabola (as shown below, it is not what I expected).
View Image
I had tried to draw the Path with a thicker Paint first and draw the Path again with a transparent and thinner Paint. But the problem is: there may be other things drawn on the Canvas. Doing so will cover other things intersecting with the Path.
What do you mean? If the first path-line covers other things drawn, it's ok the inner line would also. If the first line does not cover anything the 2nd line won't cover either.
When do you face the issue of having the first line not cover something while the thinner line does?
I don't know alot about graphics and drawings but I am trying to do something on canvas, and that is using vector graphics instead of bitmap to draw path on canvas with finger , I cant find any documentation or tutorials to understand how to do that, but I know that this implementation is used by some drawing apps.
According to my searching I deduced that using vector graphics will never show pixels on the edges of the path even if you zoomed.
Please suggest any thing that might help me use vector graphics and attach it to canvas to draw, thanks.
If you just want to draw with the finger :
Assuming you have a custom View that covers the drawing area ...
On onTouch handler on ACTION_DOWN create a new Path object with origin at touch point, on ACTION_MOVE you add new segments to the Path and call invalidate().
On onDraw you draw the Path on the Canvas.
I have a circle image(image1) and i am getting one more circle image(image2) dynamically. Now i want to fit the image2 in the image1. is it possible?if yes, How can we implement it.
Image1
You should be able to draw it within the bounds of the canvas of your image. Specifically you can grab the width/height of the second image and then change the drawing positioning of your bitmap by drawing it manually on a canvas and then controlling the X/Y offsetting during the drawing procedure.
Something like this
This is if your source image is at a fixed resolution (ideal). The concept would be to build the image using the Canvas object and then superimpose the other image on top of it. And build a bitmap from that.
I am working on a concept that I have to draw a line over SurfaceView and want to drag, zoom in & zoom out as well as movement of that line according to image movement.
I'd take a look at the canvas, paint, and path classes in the android API.
I want to draw a big image on canvas, and after that I want to move that canvas so it shows me different part of this image. Without repainting it (or eventually repainting only the needed part). How is it done in android?
Check this method. All you need to do is to specify horizontal and vertical distance to move your canvas. You can also scale, rotate or even apply custom matrix on canvas. This tutorial also might be helpful.