reza1373
پنج شنبه 03 اسفند 1391, 23:17 عصر
به نظرتون مشکل کجایه یه ارور میده به خطی که مشخص کردم
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim bmp As Bitmap
bmp = New Bitmap(PictureBox1.Image)
Dim color As Color, r As Byte, g As Byte, b As Byte, x As Long, y As Long, out As Long
x = 0
y = 1
Do
color = bmp.GetPixel(x, y)
x = x + 1
If x = 240 Then
x = 0
y = y + 1
End If
If y = 320 Then Exit Sub
b = color.B
SetBit(out, 0, Math.Sign(b And (2 ^ 1)))
SetBit(out, 1, Math.Sign(b And (2 ^ 2)))
SetBit(out, 2, Math.Sign(b And (2 ^ 3)))
SetBit(out, 3, Math.Sign(b And (2 ^ 4)))
SetBit(out, 4, Math.Sign(b And (2 ^ 5)))
g = color.G
SetBit(out, 5, Math.Sign(g And (2 ^ 1)))
SetBit(out, 6, Math.Sign(g And (2 ^ 2)))
SetBit(out, 7, Math.Sign(g And (2 ^ 3)))
SetBit(out, 8, Math.Sign(g And (2 ^ 4)))
SetBit(out, 9, Math.Sign(g And (2 ^ 5)))
SetBit(out, 10, Math.Sign(g And (2 ^ 6)))
r = color.R
SetBit(out, 11, Math.Sign(r And (2 ^ 1)))
SetBit(out, 12, Math.Sign(r And (2 ^ 2)))
SetBit(out, 13, Math.Sign(r And (2 ^ 3)))
SetBit(out, 14, Math.Sign(r And (2 ^ 4)))
SetBit(out, 15, Math.Sign(r And (2 ^ 5)))
SerialPort1.WriteLine(out.ToString() + Chr(13)) '<<<<<<<<<<<<<<<<<<-------------------
For a = 0 To 80000
Next
Loop
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim bmp As Bitmap
bmp = New Bitmap(PictureBox1.Image)
Dim color As Color, r As Byte, g As Byte, b As Byte, x As Long, y As Long, out As Long
x = 0
y = 1
Do
color = bmp.GetPixel(x, y)
x = x + 1
If x = 240 Then
x = 0
y = y + 1
End If
If y = 320 Then Exit Sub
b = color.B
SetBit(out, 0, Math.Sign(b And (2 ^ 1)))
SetBit(out, 1, Math.Sign(b And (2 ^ 2)))
SetBit(out, 2, Math.Sign(b And (2 ^ 3)))
SetBit(out, 3, Math.Sign(b And (2 ^ 4)))
SetBit(out, 4, Math.Sign(b And (2 ^ 5)))
g = color.G
SetBit(out, 5, Math.Sign(g And (2 ^ 1)))
SetBit(out, 6, Math.Sign(g And (2 ^ 2)))
SetBit(out, 7, Math.Sign(g And (2 ^ 3)))
SetBit(out, 8, Math.Sign(g And (2 ^ 4)))
SetBit(out, 9, Math.Sign(g And (2 ^ 5)))
SetBit(out, 10, Math.Sign(g And (2 ^ 6)))
r = color.R
SetBit(out, 11, Math.Sign(r And (2 ^ 1)))
SetBit(out, 12, Math.Sign(r And (2 ^ 2)))
SetBit(out, 13, Math.Sign(r And (2 ^ 3)))
SetBit(out, 14, Math.Sign(r And (2 ^ 4)))
SetBit(out, 15, Math.Sign(r And (2 ^ 5)))
SerialPort1.WriteLine(out.ToString() + Chr(13)) '<<<<<<<<<<<<<<<<<<-------------------
For a = 0 To 80000
Next
Loop
End Sub