[source]FindColorSpiral

Discussion in 'Programming General' started by slashshot007, Dec 23, 2007.

[source]FindColorSpiral
  1. Unread #1 - Dec 23, 2007 at 11:21 AM
  2. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    [source]FindColorSpiral

    credits to to cruel, i just converted it to vb.net, this also uses a picture, instead of the traditional getPixel thing, so u may be able to customize this for findBitmap. I may do that later on, and i will post the source if i get it to work.
    Code:
        Function FindColorSpiral(ByVal color As Color, ByVal StartPoint As Point, ByVal Area As Rectangle) As Point
            Dim AreaSize As Size = Area.Size
            Dim TempBitmap As New Bitmap(AreaSize.Width, AreaSize.Height)
            Graphics.FromImage(TempBitmap).CopyFromScreen(Area.Location, New Point(), AreaSize)
            Dim x As Integer = StartPoint.X - Area.X
            Dim y As Integer = StartPoint.Y - Area.Y
            Dim direction, length, i As Integer
            direction = 0 : length = 1
            If color = TempBitmap.GetPixel(x, y) Then Return New Point(Area.X + x, Area.Y + y)
            Do Until (x < 2) Or (y < 2) Or (x > Area.Width - 2) Or (y > Area.Height - 2)
                For i = 1 To length
                    Select Case direction
                        Case 0 : y = y - 1
                        Case 1 : x = x + 1
                        Case 2 : y = y + 1
                        Case 3 : x = x - 1
                    End Select
                    If color = TempBitmap.GetPixel(x, y) Then Return New Point(Area.X + x, Area.Y + y)
                Next i
                direction = (direction + 1) Mod 4
                If (direction Mod 2) = 0 Then length = length + 1
            Loop
            Return New Point(-1, -1)
        End Function
     
  3. Unread #2 - Jan 14, 2008 at 3:09 PM
  4. elborio
    Referrals:
    0

    elborio Guest

    [source]FindColorSpiral

    gets me always a pixel 1 could you explain me or says how to make coler picker and specifie the color
    but i made a image box with back grond black an it couldnt find the image box.

    waht i do wrong:
    Code:
     varco = Color.Black
            Label2.Text = FindColorSpiral(varco, New Point(15, 70), New Rectangle(15, 70, 800, 540)).ToString [CODE]
     
  5. Unread #3 - Jan 16, 2008 at 9:22 AM
  6. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    [source]FindColorSpiral

     
  7. Unread #4 - Jan 18, 2008 at 12:31 PM
  8. elborio
    Referrals:
    0

    elborio Guest

    [source]FindColorSpiral

    made something like a color finder using part of your script.
    BUT , u know how check if left mouse is pressed?:p
     
  9. Unread #5 - Jan 19, 2008 at 8:10 PM
  10. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    [source]FindColorSpiral

    Code:
    Private Sub btnGetColor_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnGetColor.MouseDown
    		tmrGetColor.Start()
    	End Sub
    
    
    	Private Sub tmrGetColor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGetColor.Tick
    		Dim TempBitmap As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    		Graphics.FromImage(TempBitmap).CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, New Point(), Screen.PrimaryScreen.Bounds.Size)
    		PictureBoxColor.BackColor = TempBitmap.GetPixel(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y)
    	End Sub
    
    	Private Sub btnGetColor_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnGetColor.MouseUp
    		tmrGetColor.Stop()
    	End Sub
    that should help u figure it out.

    edit: its not even that fast. flaming idiots has a really fast good findcolorspiral. i reccomend u ask him, i may post it but that requires me to find it.
     
< mouse functions & color checker & running in background | can you send packets to rs client >

Users viewing this thread
1 guest


 
 
Adblock breaks this site