沿 GraphicsPath 创建新图片

Create a new picture along the GraphicsPath

有什么方法可以将 GraphicsPath 和包含的图形复制到新图片中吗?
我有矩形,可用的 GraphicsPath 点。路径肯定在矩形内。
我已经用谷歌搜索了,但结果很差。到目前为止,我只能将某个区域(矩形)复制到新图片中,查看源代码。

Using Extracted As Bitmap = New Bitmap(rect.Width, rect.Height, Imaging.PixelFormat.Format32bppArgb)
    Using Grp As Graphics = Graphics.FromImage(Extracted)
        Grp.DrawImage(Picture1, 0, 0, rect, GraphicsUnit.Pixel)
    End Using
    If System.IO.Directory.Exists("C:\Users\xy\Desktop") Then
        Extracted.Save("C:\Users\xy\Desktop.png", Imaging.ImageFormat.Png)
    End If
End Using

我找到了一些东西here:

这是翻译成 VB.Net 并启用 Option Strict 和 Option Infer Off 的解决方案。

Using bmpSource As Bitmap = New Bitmap(Form1.Pfad_Bild)
                    Dim rectCutout As RectangleF = gp.GetBounds()
                    Using m As Matrix = New Matrix()
                        m.Translate(-rectCutout.Left, -rectCutout.Top)
                        gp.Transform(m)
                    End Using
                    Using bmpCutout As Bitmap = New Bitmap(CInt(rectCutout.Width), CInt(rectCutout.Height))
                        Using graphicsCutout As Graphics = Graphics.FromImage(bmpCutout)
                            graphicsCutout.Clip = New Region(gp)
                            graphicsCutout.DrawImage(bmpSource, CInt(-rectCutout.Left), CInt(-rectCutout.Top))
                            If System.IO.Directory.Exists("C:\Users\xy\Desktop") Then
                                bmpCutout.Save("C:\Users\xy\Desktop.png", Imaging.ImageFormat.Png)
                            End If
                        End Using
                    End Using
                End Using