Hi, i'm fairly new to .NET after getting tired of using VB6 due to the lack of functionality. I'm trying to create a log on method for a system which will involve users selecting a colour from a paint panel and then placing/drawing the colour in 1 or more tiles of a grid, basically a 3x3 grid in which for example they selected the blue colour and drew in the top left tile and the bottom left tile. The logon is selecting the correct colour and placing the colour in the appropriate tile. What i want them to be able to do is place even a single pixel of colour so it has a high accuracy. So far i have a timer which loops from the width of the grid to the height of the grid.
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim BMP As New Drawing.Bitmap(1, 1)
Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
New Drawing.Point(0, 0), BMP.Size)
For i = 0 To BMP.Width - 1
Dim Pos As Point
For j = 0 To BMP.Height - 1
Dim Pixel As Drawing.Color = BMP.GetPixel(i, j)
Pos.X = i
Pos.Y = j
Windows.Forms.Cursor.Position = New System.Drawing.Point(i, j)
If Pixel.R = 255 And Pixel.G = 174 And Pixel.B = 201 Then
MsgBox("Colour found " & Pixel.R)
Timer1.Enabled = False
End If
Next
Next
MsgBox("Not found")
Timer1.Enabled = False
End Sub
To start with i have just hard coded the colour i want it to detect. At present it produces an error. Parameter must be positive and < Width the error is on System.Drawing.Point(i,j). If i place the mouse over the colour then run the program it will say it has been found, but otherwise it wont find the colour. I believe i am not updating the location of the pixel or something to that effect.
Thanks in advance
TG