我正在尝试使用GraphicsPath绘制一个类似于“文件夹”的图像。
我创建路径的函数如下:
Public Function FolderRect(ByRef r As Rectangle) As System.Drawing.Drawing2D.GraphicsPath
Dim p As New System.Drawing.Drawing2D.GraphicsPath
Dim iTabWidth As Integer = 30
Dim iTabHeight As Integer = 12
With p
Call p.AddLine(r.Left, r.Top, r.Left + iTabWidth, r.Top)
Call p.AddLine(r.Left + iTabWidth, r.Top, r.Left + iTabWidth, r.Top + iTabHeight)
Call p.AddLine(r.Left + iTabWidth, r.Top + iTabHeight, r.Right, r.Top + iTabHeight)
Call p.AddLine(r.Right, r.Top + iTabHeight, r.Right, r.Bottom)
Call p.AddLine(r.Right, r.Bottom, r.Left, r.Bottom)
Call p.AddLine(r.Left, r.Bottom, r.Left, r.Top)
Call p.CloseFigure()
End With
Return p
End Function代码在我看来是正确的,但结果并不是我所期望的:

(我使用图像编辑器创建了“正确”版本)。
这可能是GraphicsPath中的一个错误?
这是PathPoints的样子:

这是"r“的样子:

发布于 2016-01-29 06:34:45
图形路径几乎肯定是正确的。可以通过查看图形路径的PathPoints属性来验证这一点。
在绘制图形路径时,可能存在一些舍入误差。尝试使路径与目标位图的大小相同。
https://stackoverflow.com/questions/35072697
复制相似问题