Hey there, i'm stuck on this!
I need to crop every letter square out of
this picture, and store each letter in an image array of some sort, basically the reason for this is to compare the images to a preset alphabet of these letters to figure out what letter it is (OCR would work better for this, but i can't find a free working OCR class for vb.net).
I am using the System.Drawing Library
I hope someone can help me! :)
Picture here
here is what I had that doesn't work:
Dim grid(4, 4) As Point
Dim letters() As Image
Dim boardCoord As New Point(0, 0)
Dim curLetter As Integer = 0
Dim b As Image
Dim gRec(4, 4) As Rectangle
Private Sub captureBoard()
Dim tPoint As Point
b = PictureBox1.Image
For i As Integer = 0 To 3
For ii As Integer = 0 To 3
tPoint = New Point(boardCoord.X + (25 * ii), boardCoord.Y + (25 * i))
grid(ii, i) = tPoint
Next
Next
For x As Integer = 1 To 4
For y As Integer = 1 To 4
gRec(x, y) = New Rectangle(grid(x, y), New Size(20, 20))
Next
Next
For i As Integer = 1 To 16
For x As Integer = 1 To 4
For y As Integer = 1 To 4
Dim j = gRec(x, y)
letters(i) = CropLetters(b, j.X, j.Y, j.Size.Width, j.Size.Height)(i)
Next
Next
Next
End Sub
Private Function CropLetters(ByVal board As Bitmap, ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer) As Image()
Dim rect As Rectangle = New Rectangle(X, Y, Width, Height)
Dim tBitmaps() As Bitmap
For i As Integer = 1 To 16
Dim g As Graphics = Graphics.FromImage(board)
g.DrawImage(tBitmaps(i), 0, 0, rect, GraphicsUnit.Pixel)
Next
Return tBitmaps
End Function