Search code examples
vb.netimagepictureboxsystem.drawing

convert group of points to create an image vb.net


I have a group of points. I know how to draw the polygon in the panel but now I don't know how to make it an image.

tried googling it but I can't find the answer

how can I make it an image? is it possible?


Solution

  • Dim points(5) As Point
    points(0) = New Point(50, 10)
    points(1) = New Point(90, 30)
    points(2) = New Point(75, 70)
    points(3) = New Point(25, 70)
    points(4) = New Point(10, 30)
    points(5) = New Point(50, 10)
    
    Dim img As New Bitmap(100, 100)
    Dim gfx As Graphics = Graphics.FromImage(img)
    gfx.DrawLines(Pens.Black, points)
    Dim strFilename As String = "C:\Junk\Junk.png"
    img.Save(strFilename, System.Drawing.Imaging.ImageFormat.Png)
    gfx.Dispose()
    img.Dispose()
    Process.Start(strFilename)