android - 在特定坐标处转换 Bitmap 或 ImageView

标签 android bitmap imageview coordinates transform

我正在尝试通过将点拖动到特定坐标来转换位图和 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/

相关文章:

Android 2.2 SDK - 位图图像调整大小 nullPointerException

android - 如何用半透明 View 覆盖 ImageView?

android - 如何更改 Vuforia AR 相机对焦模式?

android - Google places API 是否有关于附近餐厅菜单的信息?

java - Android:内存友好的图像字节修改

java - 如何以编程方式在中心裁剪特定尺寸的位图

android - 如何将 Base64 字符串转换为位图图像以在 ImageView 中显示?

android - 自动调整两个 TextView 的大小以显示尽可能多的内容

java - Android Studio 中的错误 - 一些奇怪的错误