我在画布上缩放和变换后的图像上绘制线条时遇到问题,对于变换后的图像,我可以在图像上绘制线条,但如果图像缩放(放大或缩小),则使用手指触摸意外绘制线条像素。由于我正在研究绘画应用程序,但对此没有更多的了解,所以我需要您的帮助,我在谷歌上搜索了它,但没有运气,我
在这里没有找到任何东西,第一张图像默认工作正常,在第二个移动图像工作正常,正确绘制了线条

而在第三个缩放图像上无法正确绘制,我的意思是如果从左上角/左上角开始绘制,则绘制的线点会有所不同,如下所示

如果您需要代码,请说出来,我将编辑问题
I have problem to draw line on scaled and transformed image on canvas, well for the transformed I am able to draw line on image but if the image was scaled(zoom in or out) then line drew unexpectedly pixel using finger touch. As I am working on paint application but didn't have knowledge more about this so I need your help, I have searched it on google but no luck, I didn't found any thing
here is the images 1st is default working properly and in second moved image working properly drew the line properly

while in third on scaled image not properly draw, I mean if start draw from the top/left corner then the line drew point was different like here

if you need for code then say it I'll edit the question
发布评论
评论(1)
好吧,经过多次实施,我得到了解决方案。
这是我在 onDraw() 中绘图的代码,
在这里您必须检查比例因子值以恢复画布。如果比例因子值默认为 1.f 并且图像刚刚移动,则在绘制线/路径后恢复,如果比例因子不等于 1.f(默认),则首先恢复画布,然后绘制线/使用手指触摸绘制时的路径。
这是我的 onTouch() 代码
Ok after many implementation I got the solution for this.
This is my code for drawing in onDraw()
here you have to check for the scale factor value for restore the canvas. If the scale factor value was default that is 1.f and image was just move then restore after the draw line/path, if the scale factor was not equals to the 1.f (default) then restore the canvas 1st then draw line/path at using finger touch drawing time.
here is my onTouch() code