1

I am trying to draw a "folder" like image using a GraphicsPath.

My function to create the path is the following:

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

The code looks right to me, but the result is not what I expected:

enter image description here

(I created the "correct" version using an image editor).

May this be a bug in the GraphicsPath?

This is what the PathPoints look like: enter image description here

This is what "r" looks like: enter image description here

Maiken Roskilde
  • 447
  • 3
  • 14

1 Answers1

0

The graphics path is almost certainly correct. You can verify this by looking at the PathPoints property of the graphics path.

It's possible that there is some roundoff error when you draw the graphics path. Try making the path the same size as the target bitmap.

xpda
  • 15,585
  • 8
  • 51
  • 82