Blake81
Well-known member
I'm trying to use a gradient on a PNG file that is one solid color (the shape in the PNG is), but I'm getting "Parameter is not valid". I just saw that PathPoints is read only, so I'm trying to figure out how to add points to a path. Is this possible, and how can I do it? Here's an example of the image I want to fill.
It's all one color, so I'm grabbing that color with the Picturebox MouseDown event and then searching for each pixel with that color. Here's my code.
It's all one color, so I'm grabbing that color with the Picturebox MouseDown event and then searching for each pixel with that color. Here's my code.
VB.NET:
For x = 0 To PictureBox1.Image.Width - 1
pt.X = x
For y = 0 To PictureBox1.Image.Height - 1
pt.Y = y
color2 = DirectCast(PictureBox1.Image, Bitmap).GetPixel(pt.X, pt.Y)
If color2 = mycolor Then
ListBox1.Items.Add(pt.X & "," & pt.Y)
End If
Next
Next
For xp = 0 To ListBox1.Items.Count - 1
Dim ptstring As String = ListBox1.Items.Item(xp)
Dim ptstringsplit() As String = ptstring.Split(",")
pt2.X = ptstringsplit(0)
pt2.Y = ptstringsplit(1)
Next
Dim g As Graphics = Graphics.FromImage(bmp)
g.FillPath(Brushes.LightSalmon, pth)
PictureBox1.Image = bmp
PictureBox1.Refresh()