Move an Image bitmap on a Path drawn on layout background - android

I need to move a bitmap image on a path drawn in background of my layout, it can be also a movement of the bitmap inside another bitmap. The movement is caused by smartphone's accelerometer. Any suggestion?

Shortest answer ever - 'Use OpenGL, Luke'
You can also use one of OGL frameworks i.e. AndEngine.

Related

Drawing on canvas using vector graphics android

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.

Capturing android touch drawing coordinates as paths

Using an example found here:
http://www.vogella.com/tutorials/AndroidTouch/article.html I'm able to draw a path every time a finger touches the screen and that works great, Is there any way that I can capture that drawn path and reproduce it in another view in other coordinates? Like capturing the full drawn image and reproducing it scaled in a segment of the other view?
Sorry for my bad english
You can save your drawn image and save it as a bitmap. Then you can scale it with Matrix or Canvas and redraw it by calling to where you want to draw

Drawing to a new Bitmap and then using that in my onDraw

I would like to display several rings with different coloured sections (see below). The colour of the sections, however, cannot be know in advance, so I will need to draw these dynamically.
I know I could draw directly to the canvas but, once I have them, I would like to animate these rings, rotate them, have them overlap etc. It seemed, therefore, that the easiest and possibly least expensive approach would be to create them in advance, in memory, as transparent pngs and then just draw them in onDraw.
My problem is the only methods I can find to do this are setPixel. Is there not a way I could use drawing tools, like in Canvas, to draw to an empty bitmap, once, then use that bitmap with my canvas in onDraw?
I feel like I am missing a piece in the puzzle. Any help would be greatly appreciated.
You can create a Bitmap that is the size you want the ring to be and then create a Canvas the same size. Call setBitmap() on the Canvas and it will draw on to that for you. Then you can build your circle and have a bitmap to hold onto and use just like any other resource.

android - How to fit circle image in another circle image

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.

Where does Android.Graphics.Camera set its X,Y, and Z axis when canvas is set to a bitmap?

I want to get a bitmap and manipulate it in the following way:
I have created an empty bitmap, on this bitmap, I drew what I needed. Now I need to distorted in a way similar to this because I will then be drawing the whole thing ontop of another bitmap. Think of it as applying a texture to a box. The box simply being a picture of a box. The way that I see myself doing this is creating bitmaps off the main bitmap and drawing them onto the final bitmap through a matrix modified by Graphics.Camera.getMatrix().
I already have this working, but my problem is understanding just exactly how to manipulate the camera. I don't know where the camera creates its X Y and Z axis within the matrix. Or where does the matrix get applied. Or just how it all comes together.
When drawing on canvas set to view, I know I can rotate the canvas and draw from there to create a straight diagonal line, for example in a game engine to draw a projectile acting on two vectors. And I know when working on OpenGL, there is a state machine approach and I can imagine where the matrix is in 3D space. But I just don't understand how Camera, Matrix, and bitmap all relate.
From what I've looked up, I managed to set up the basic solution to this but havent been able to understand just exactly how to tweak this in order to get the right rotations. I have read the documentation but it doesn't really explain the relationship between Camera, Matrix, and canvas beyond the fact that Camera modifies a matrix and then canvas can draw something based on that matrix.
Can anyone explain how I would go about doing what I have in the picture? I already know that I'll be creating a bitmap from region in original bitmap. Then combining the two, to create what is on the right column , and then rotating the canvas/bitmap and getting another bitmap from green section and repeat the whole thing again.
Thanks
Camera is just a utility class that generates a Matrix you can use on Canvas. The generated Matrix contains the appropriate transform. You said it yourself:
it doesn't really explain the relationship between Camera, Matrix, and
canvas beyond the fact that Camera modifies a matrix and then canvas
can draw something based on that matrix.
That's all there is to it really :)

Categories

Resources