Regency Posted January 24, 2008 Share Posted January 24, 2008 I found a udf somone sent me, and it uses a function they wrote. The udf uses arrays and i tried to read them and think about how i would go about doing what i wanted and dont understand the whole array things so i am at a loss. So what i am trying to do is understand how i would be able to save the specific cords of the place i want it to search in the code and have it compare it to a already calculated number of pixels in the area and figure out which amount of pixels it matchs, Like in area 100,100 there are 45 pixels of the color Pink (hex codes used), and this script looks in that area and finds 10 pink, so ir compares it to the base values i have set up and now i know that picture it was searching at 100,100 is actually color blue with pink underlaying. If you dont understand post and i can try and explain UDF expandcollapse popup;================================= PixelFindAll ============================== ; Function Name: _PixelFindAll_Compare ; Description: Finds all instances of a pixel within a given area and returns array with Total and all locations X and Y. ; Compare allows you to skip pixels within a given distance to each other. ; Requires: None ; Parameters: $Pixel Colour value of pixel to find (in decimal or hex). ; $XDist Horizontal distance from found pixel to skip before continueing search (moving right) ; $YDist Vertical distance from found pixel to skip before continueing search (moving down) ; $sv Shade Varience ; $SB_l left coordinate of total area to search. Default is 0 (far left side of screen) ; $SB_t top coordinate of total area to search. Default is 0 (top most Side of screen) ; $SB_r Right coordinate of total area to search. Default is @DesktopWidth (Far Right side of screen) ; $SB_b Bottom coordinate of total area to search. Default is @DesktopHeight (Bottom most side of screen) ; Syntax: _PixelFindAll($pixel, $XDist, $YDist[, $sv, $SB_l, $SB_t, $SB_r, $SB_b]) ; Author(s): ofLight ; Returns: $Array[0][0] = 0 on failure, $Array on success ;=============================================================================== Func _PixelFindAll($pixel,$XDist,$YDist,$sv=0,$SB_l=0,$SB_t=0,$SB_r=@DesktopWidth,$SB_b=@DesktopHeight) $SB_b_Max = $SB_b $SB_l_Max = $SB_l Dim $Array[2][2] $Array[0][0] = "0" $Count = "0" While 1 $xy = PixelSearch($SB_l,$SB_t,$SB_r,$SB_b,$pixel,$sv) If @error And $SB_b = $SB_b_Max Then SetError(1) Dim $Array2[2][2] $Array2[0][0] = "0" $Count = "0" For $i = 1 to $Array[0][0] $Write = 1 For $j = $i+1 to $Array[0][0] $VarX = _CompareNumbers($Array[$i][0], $Array[$j][0], $XDist) If $VarX = 0 Then $VarY = _CompareNumbers($Array[$i][1], $Array[$j][1], $YDist) If $VarY = 0 Then $Write = 0 EndIf Next If $Write = 1 Then $Count = $Count+1 $Array2[0][0] = $Count ReDim $Array2[$Count+1][2] $Array2[$Count][0] = $Array[$i][0] $Array2[$Count][1] = $Array[$i][1] EndIf Next Return $Array2 ElseIf @error Then $SB_t = $SB_b + 1 $SB_b = $SB_b_Max $SB_l = $SB_l_Max Else $Count = $Count+1 $Array[0][0] = $Count ReDim $Array[$Count+1][2] $Array[$Count][0] = $xy[0] $Array[$Count][1] = $xy[1] $SB_t = $xy[1] $SB_b = $SB_t $SB_l = $xy[0]+1+$YDist EndIf WEnd EndFunc;========================== PixelFindAll =============================== Func _CompareNumbers($Number1, $Number2, $byhowmuch);SUB Function ;Verify that $Number1 is more than $byhowmuch from $Number2 ;Returns 0 if within $byhowmuch If $Number1 = $Number2 Then Return 0 ElseIf $Number1 > $Number2 Then If ($Number1-$byhowmuch) >= $Number2 Then Return 1 ElseIf $Number1 < $Number2 Then If ($Number1+$byhowmuch) <= $Number2 Then Return 1 EndIf Return 0 EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now