Android 在多边形上绘制位图
我正在尝试在边数超过 4 的多边形上绘制位图。我正在使用 opengl 来执行此操作,但我意识到在 2d 中,Canvas 中有一个名为 drawBitmapMesh 的方法可以实现此目的。它适用于 4 边多边形,但不适用于 5 边多边形。 这有效
float verts[] = {0,0, 0,10, 0,20 ,0,30, 10,0, 10,10, 10,20, 10,30, 20,0, 20,10, 20,20, 20,30, 30,0, 30,10, 30,20, 30,30};
canvas.drawBitmapMesh(bitmap, 3, 3, verts, 0, null, 0, null);
这不起作用会产生运行时错误。
float verts[] = {0,0, 0,10, 0,20 ,0,30, 0,40, 10,0, 10,10, 10,20, 10,30,10,40, 20,0, 20,10, 20,20, 20,30,20,40, 30,0, 30,10, 30,20, 30,30,30,40};
canvas.drawBitmapMesh(bitmap, 4, 4, verts, 0, null, 0, null);
I am trying to draw a bitmap on a polygon has sides more than 4. ı am dealing with opengl to do this but i realised in 2d there is a method called drawBitmapMesh in Canvas for this. It worked for 4 side polygon but not working for 5.
This works
float verts[] = {0,0, 0,10, 0,20 ,0,30, 10,0, 10,10, 10,20, 10,30, 20,0, 20,10, 20,20, 20,30, 30,0, 30,10, 30,20, 30,30};
canvas.drawBitmapMesh(bitmap, 3, 3, verts, 0, null, 0, null);
This does not work gives runtime error.
float verts[] = {0,0, 0,10, 0,20 ,0,30, 0,40, 10,0, 10,10, 10,20, 10,30,10,40, 20,0, 20,10, 20,20, 20,30,20,40, 30,0, 30,10, 30,20, 30,30,30,40};
canvas.drawBitmapMesh(bitmap, 4, 4, verts, 0, null, 0, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 SDK 文档:
您的数组中有 38 个值,而上面的参数计算给出: (4+1)*(4+ 1)*2 + 0 = 50 个值...
From the SDK documentation:
You have 38 values in your array, whereas the above calculation with the parameters gives: (4+1)*(4+1)*2 + 0 = 50 values ...