Reputation: 531
I am trying to transform bitmap and imageview by dragging points to specific coordinates Example this is drawing app. Which is the best way to make it ? Should i use OpenGL ? Thank You
EDIT: I fixed by using canvas.drawBitmapMesh thank you all for your help i really appreciate it .
Upvotes: 2
Views: 945
Reputation: 9103
You can try creating second mutable bitmap like this
Bitmap originalBitmap;
Bitmap b = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b)
Then you can draw original bitmap on top of new bitmap applying transformations. See Canvas API for more details.
For example use the following method:
c.drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
Update
Regarding use of Matrix, it's just a guess, you can try method mapPoints(float[] src, float[] dest). I also did a quick search on Google and found web page with examples. Have a look.
Update 2
Dardan was able to achieve his goal with the following method:
drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint);
Method description:
Draw the bitmap through the mesh, where mesh vertices are evenly distributed across the bitmap. There are meshWidth+1 vertices across, and meshHeight+1 vertices down. The verts array is accessed in row-major order, so that the first meshWidth+1 vertices are distributed across the top of the bitmap from left to right. A more general version of this method is drawVertices().
Upvotes: 1