我正在尝试通过将点拖动到特定坐标来转换位图和 ImageView Example这是绘图应用程序。哪种方法最好?我应该使用 OpenGL 吗?谢谢你
编辑:我通过使用 canvas.drawBitmapMesh 修复了,谢谢大家的帮助,我真的很感激。
最佳答案
你可以尝试像这样创建第二个可变位图
Bitmap originalBitmap;
Bitmap b = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b)
然后您可以在应用变换的新位图之上绘制原始位图。参见 Canvas API 了解更多详情。
例如使用下面的方法:
c.drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
更新
关于Matrix的使用,只是猜测,可以试试mapPoints(float[] src, float[] dest)方法。我还在 Google 上进行了快速搜索,找到了 web page有例子。看看。
更新 2
Dardan 能够通过以下方法实现他的目标:
drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint);
方法说明:
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().
关于android - 在特定坐标处转换 Bitmap 或 ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25141639/