Imports System.Drawing
Public Class TypeR
Dim ofd As New OpenFileDialog
Dim x As Integer = 0
Dim y As Integer = 0
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
ofd.InitialDirectory = ("C:\TypeR")
ofd.ShowDialog()
textbox3.Text = ofd.FileName
PictureBox2.ImageLocation = textbox3.Text
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
If Timer1.Enabled = True Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
myx.Text = "0"
myy.Text = "0"
End If
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Timer1.Interval = speed.Text
Dim mydrawing As System.Drawing.Bitmap = System.Drawing.Bitmap.FromFile(ofd.FileName)
Dim thecolor As Color
thecolor = mydrawing.GetPixel(myx.Text, myy.Text)
r.Text = thecolor.R
g.Text = thecolor.G
b.Text = thecolor.B
myx.Text = myx.Text + 1
If myx.Text = mydrawing.Width Then
myy.Text = myy.Text + 1
myx.Text = 0
Else
End If
If myx.Text = mydrawing.Height - 1 And myy.Text = mydrawing.Width - 1 = True Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
End If
Dim Myr As Integer = r.Text
Dim Myg As Integer = g.Text
Dim Myb As Integer = b.Text
PictureBox1.BackColor = Color.FromArgb(Myr, Myg, Myb)
If myy.Text = 30 Then
Timer1.Enabled = False
End If
End Sub
End Class
Dim sz(9) As String
sz(0) = "0000110000001111000011001100110000110110000110110000110110000110011001100001
11100"
sz(1) = "0000110000000110000001110000011110000000110000000110000000110000000110000000
11000000011000001111110"
sz(2) = "0001111000011001100110000110000000110000001100000011000000110000001100000011
00000011111111"
sz(3) = "0011111000110001100000000110000001100000111000000001100000000110000000110110
00110001111100"
sz(4) = "0000001100000011100000111100001101100011001100110001100111111110000001100000
00110000000110"
sz(5) = "0111111100110000000110000000110111000111001100000000110000000110110000110011
00110000111100"
sz(6) = "0001111000011001100110000100110000000110111000111001100110000110110000110011
00110000111100"
sz(7) = "0111111110000000110000000110000001100000011000000110000001100000011000000110
00000011000000"
sz(8) = "0001111000011001100110000110011001100001111000011001100110000110110000110011
00110000111100"
sz(9) = "0001111000011001100110000110110000110011001110001110110000000110010000110011
00110000111100"
Dim x As Integer = 0
Dim y As Integer = 0
Dim nLine As Integer = 0
Dim nGroup As Integer = 0
Dim szGroup(5) As String
Dim szTemp As String = ""
Dim bmp As Bitmap = pic.Image.Clone
For y = 11 To pic.Height - 10 Step 1
nLine = 1
nGroup = 0
For x = 7 To pic.Width - 9 Step 1
If bmp.GetPixel(x, y).ToArgb = Color.White.ToArgb Then
szTemp = szTemp & "0"
ElseIf bmp.GetPixel(x, y).ToArgb = Color.Black.ToArgb Then
szTemp = szTemp & "1"
End If
If nLine = 9 Then
szGroup(nGroup) = szGroup(nGroup) & szTemp
szTemp = ""
nLine = 1
nGroup += 1
Else
nLine += 1
End If
Next
Next
For x = 0 To 5
For y = 0 To 9
If szGroup(x) = sz(y) Then
rtb.Text = rtb.Text & y.ToString
End If
Next
Next
Dim OFD As New OpenFileDialog
Dim WhitePixels As Integer = 0
Dim BlackPixels As Integer = 0
If Not OFD.ShowDialog() = DialogResult.Cancel Then
Dim pic As New Bitmap(OFD.FileName)
Dim Black As Color = Color.Black
Dim White As Color = Color.White
For x As Integer = 0 To pic.Width - 1
For y As Integer = 0 To pic.Height - 1
If (pic.GetPixel(x, y).ToArgb = Black.ToArgb) Then
BlackPixels += 1
End If
If (pic.GetPixel(x, y).ToArgb = White.ToArgb) Then
WhitePixels += 1
End If
Next
Next
End If
MessageBox.Show("White Pixels: " & WhitePixels & Environment.NewLine & "Black Pixels: " & BlackPixels)