还是要找异或的pen ,有谁知道的有奖啦:)
俺搜到 C++里有俺搜到的:
************
1楼 fidt982 (痴心绝对~0~) 回复于 2005-03-10 12:11:42 得分 0
用异或的方式,将同一条线画两遍就可以了
Top
2楼 tomlance (旧好隔良缘) 回复于 2005-03-10 14:49:16 得分 0
Canvas->Pen->Mode = pmXor;
//todo:add your source code here.
****************
俺不明白,如果翻译到vb.net怎么用?
问题点数:30、回复次数:6Top
1 楼wuyazhe(wyz&xyl)回复于 2006-05-01 22:48:45 得分 10
GDI+不支持异或笔Top
2 楼helendeer(只要精神不滑坡,方法总比困难多)回复于 2006-05-03 21:09:50 得分 0
楼上的师兄请问那怎么能实现橡皮筋功能?有什么办法吗?Top
3 楼laviewpbt(人一定要靠自己)回复于 2006-05-03 22:59:06 得分 20
http://www.codeproject.com/dotnet/rubberbandline.asp
Drawing and Editing Lines with GDI
很久前看过,好象是用bitblt实现的,感觉写的有点乱Top
4 楼laviewpbt(人一定要靠自己)回复于 2006-05-03 23:17:43 得分 0
这个可能看起来简单点
http://www.codeproject.com/csharp/lineditor.asp
其实他的原理和bitblt感觉差不多
如果C#你不会可以把对应的 vb.net的代码发给你!
不过这样的做法缺点就是当画线时,CPU的使用率非常高 。
Top
5 楼laviewpbt(人一定要靠自己)回复于 2006-05-04 22:44:37 得分 0
给你一段简短的代码
Private bmpBack As Bitmap = Nothing
Private IsDown As Boolean '是否以按下鼠标
Dim se As New StartEndPoint
Dim array As New ArrayList '存储所有线条起点和终点的坐标
Public Structure StartEndPoint
Dim PointStart As PointF '起点
Dim PointEnd As PointF '终点
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bmpBack = New Bitmap(pic.Width, pic.Height)
Graphics.FromImage(bmpBack).Clear(Color.White) '这样pic.image不为空
pic.Image = CType(bmpBack.Clone(), Bitmap)
bmpBack.Dispose()
End Sub
Private Sub pic_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseDown
se.PointStart = New PointF(e.X, e.Y) '按下时记录该起点坐标
IsDown = True
End Sub
Private Sub pic_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseMove
If IsDown = True Then
se.PointEnd = New PointF(e.X, e.Y)
array.Add(se) '增加终点,临时的
DrawLine(e.X, e.Y) '这里应该有其他的方法
array.RemoveAt(array.Count - 1) '画完后删除
End If
End Sub
Private Sub pic_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseUp
se.PointEnd = New PointF(e.X, e.Y) '添加终点,
array.Add(se) '往array中增加
IsDown = False
End Sub
Private Sub DrawLine(ByVal x As Single, ByVal y As Single)
Dim g As Graphics = Nothing
g = Graphics.FromImage(pic.Image)
g.Clear(Color.White) '清楚原来画的所有线条
For Each s As StartEndPoint In array
g.DrawLine(New Pen(Color.Black), s.PointStart, s.PointEnd) '重绘所有线条
Next
g.Dispose()
pic.Refresh() '刷新
End SubTop
6 楼helendeer(只要精神不滑坡,方法总比困难多)回复于 2006-05-08 19:39:34 得分 0
感谢二位的帮忙Top




