画一条跟随鼠标的线
我想加载一张图片(PNG、JPG、位图),然后我想在图片上画一条线。
目前我使用 PictureBox 来加载我的图片:
这是我的代码的 MouseMove 部分:
If mClickOne = True Then
If Not mSetDrawPictureAlready Then
g = Graphics.FromImage(picFormular.Image)
mRawPicture = picFormular.Image
mSetDrawPictureAlready = True
End If
If mChoosenDrawFunction = DrawFunction.Ausrichten Then
g.Clear(Color.Transparent)
g.DrawImage(mRawPicture, picFormular.Location)
g.DrawLine(Pens.Red, New Point(mClickOnePosX, mClickOnePosY), New Point(e.X, e.Y))
picFormular.Refresh()
ElseIf mChoosenDrawFunction = DrawFunction.FeldMakieren Then
'Missing Code
Else
'Nothing
End If
End If
在此我可以通过单击 PointOne 和单击 PointTwo 来绘制一条线,但是如果调用 MouseMove 事件,我的图片就会消失,所以我在干净的表面上画线。
在我第一次尝试解决这个问题时,我遇到了另一个问题。如果我划定界限,我的旧界限并没有消失。所以,我的整个表面充满了数千条线条。
你们中有人知道如何解决我的问题吗?
I want to load a picture (PNG, JPG, Bitmap) and then, I want to draw a line onto my picture.
At the moment I use a PictureBox to load my picture:
Here is the MouseMove part of my Code:
If mClickOne = True Then
If Not mSetDrawPictureAlready Then
g = Graphics.FromImage(picFormular.Image)
mRawPicture = picFormular.Image
mSetDrawPictureAlready = True
End If
If mChoosenDrawFunction = DrawFunction.Ausrichten Then
g.Clear(Color.Transparent)
g.DrawImage(mRawPicture, picFormular.Location)
g.DrawLine(Pens.Red, New Point(mClickOnePosX, mClickOnePosY), New Point(e.X, e.Y))
picFormular.Refresh()
ElseIf mChoosenDrawFunction = DrawFunction.FeldMakieren Then
'Missing Code
Else
'Nothing
End If
End If
On this I can draw a line with a click on PointOne and a click on PointTwo, but my picture is disappearing if the MouseMove event is called, so I draw my line on a clean surface.
On my first try to fix the problem I got another problem. If I draw my line, my old line didn't disappear. So, my complete surface was full with thousands of lines.
Anyone of you know how to fix my problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论