$Test = Compare ( First Picture, Second Picture, Picture Width, Picture Height, Search Step )
$Test[0] = Total searched pixels in picture
$Test[1] = Percentage of equal pixel color
$Test[2] = Equal pixel color count
$Test[3] = Not equal pixel color count
#include <GUIConstants.au3> Opt("PixelCoordMode", 2) Global $Data For $i = 1 To 4 $Test = Compare("Test1.jpg", "Test" & $i & ".jpg", 75, 75, 10) If $Data = "" Then $Data = "Test" & $i & ".jpg " & $Test[1] & "% Total : " & $Test[0] & " Equal : " & $Test[2] & " Not Equal : " & $Test[3] Else $Data = $Data & @CRLF & "Test" & $i & ".jpg " & $Test[1] & "% Total : " & $Test[0] & " Equal : " & $Test[2] & " Not Equal : " & $Test[3] EndIf If $Test[1] = 100 Then $Found = "Test" & $i & ".jpg" Next MsgBox("", "", $Data) If $Found <> "" Then MsgBox("", "", $Found & " 100% match!") Func Compare($Pic1, $Pic2, $Width, $Height, $Step = 1) Local $Color[$Width + 1][$Height + 1], $Color2[$Width + 1][$Height + 1], $Var = 0, $Var2 = 0 $Compare = GUICreate("", $Width, $Height, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $Compare) $Pic = GUICtrlCreatePic($Pic1, "", "", $Width, $Height) For $y = 1 To $Height Step $Step For $x = 1 To $Width $Color[$x][$y] = PixelGetColor($x, $y) Next Next GUICtrlSetImage($Pic, $Pic2) For $y = 1 To $Height Step $Step For $x = 1 To $Width $Color2[$x][$y] = PixelGetColor($x, $y) If $Color[$x][$y] = $Color2[$x][$y] Then $Var += 1 Else $Var2 += 1 EndIf Next Next $Need = $Var + $Var2 $Result = ($Var / $Need) * 100 GUIDelete($Compare) Dim $Return[4] = [$Need, Round($Result, 1), $Var, $Var2] Return $Return EndFunc ;==>Compare
Attached Files
Edited by Jex, 05 November 2007 - 01:02 AM.






