I have an 2 dimensional array that is full of 1s and 0s such as
0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
You can see there is a square in th array. I am trying to make a function that will make a rectangle or list of rectangles based on the square. So the example would return a rectangle like
rect.x = 2
rect.y = 1
rect.width = 7
rect.height = 5
This is the code i have now but it just doe not return anything
Dim rects As New List(Of Rectangle)
For imgWidth As Integer = 0 To bow.GetUpperBound(0)
For imgHeight As Integer = 0 To bow.GetUpperBound(1)
If bow(imgWidth, imgHeight) = 1 Then
If bow(imgWidth + 1, imgHeight) = 1 And
bow(imgWidth + 2, imgHeight) = 1 And
bow(imgWidth, imgHeight + 1) = 1 And
bow(imgWidth, imgHeight + 2) = 1 Then
Dim r As New Rectangle
With r
.X = imgWidth
.Y = imgHeight
End With
For rectWidth As Integer = imgWidth To bow.GetUpperBound(0)
If bow(rectWidth, imgHeight) = 0 Then
r.Width = bow(rectWidth - 1, imgHeight)
End If
Next
For rectHeight As Integer = imgHeight To bow.GetUpperBound(1)
If bow(imgWidth, rectHeight) = 0 Then
r.Height = bow(rectHeight - 1, imgHeight)
End If
Next
rects.Add(r)
End If
End If
Next
Next
Also the array must be able to have more than one square.