#include <GUIConstants.au3>
#include<ButtonConstants.au3>
#include<WindowsConstants.au3>
Opt("PixelCoordMode", 2)
Global $Color=0xEF0000
Global $Pic
Global $U32
Global $GDI
GUICreate("", 313, 201)
$Path1 = GUICtrlCreateInput("Muestra2.bmp", 24, 48, 193, 21)
$Path2 = GUICtrlCreateInput("Muestra1.bmp", 24, 92, 193, 21)
$Browse1 = GUICtrlCreateButton("Browse", 226, 48, 61, 23, 0)
$Browse2 = GUICtrlCreateButton("Browse", 226, 92, 61, 23, 0)
$compare = GUICtrlCreateButton("&Compare", 95, 152, 127, 31, $BS_DEFPUSHBUTTON)
GUICtrlCreateGroup(" Paths ", 8, 14, 293, 123)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Browse1
$newPath=FileOpenDialog("",@MyDocumentsDir,"(*.jpg;*bmp)")
if Not @error Then
GUICtrlSetData($Path1,$newPath)
EndIf
Case $Browse2
$newPath=FileOpenDialog("",@MyDocumentsDir,"(*.jpg;*bmp)")
if Not @error Then
GUICtrlSetData($Path2,$newPath)
EndIf
Case $compare
$Pic1Path=GUICtrlRead($Path1)
$Pic2Path=GUICtrlRead($Path2)
$U32=DllOpen("user32.dll")
$GDI=DllOpen("GDI32.dll")
$Test = Compare($Pic1Path,$Pic2Path, 200,200)
DllClose($U32)
DllClose($U32)
MsgBox(4144,"",$Test)
EndSwitch
WEnd
Func Compare($Pic1, $Pic2, $Width, $Height)
Local $Color[$Width + 1][$Height + 1], $Color2[$Width + 1][$Height + 1], $Var = 0
$Test = GUICreate("", $Width, $Height, -1, -1, $WS_POPUP,$WS_EX_TOPMOST)
GUISetState()
$Pic = GUICtrlCreatePic($Pic1, "", "", $Width, $Height)
For $y = 1 To $Height
For $x = 1 To $Width
$Color[$x][$y] = PixelGetColor($x, $y)
Next
Next
GUICtrlSetImage($Pic, $Pic2)
For $y = 1 To $Height
For $x = 1 To $Width
$Color2[$x][$y] = PixelGetColor($x, $y)
If $Color[$x][$y] = $Color2[$x][$y] Then
$Var += 1
Else
dibujar($x,$y)
EndIf
Next
Next
$Need = $Height * $Width
$Result = ($Var / $Need) * 100
;~ GUIDelete($Test)
Return Round($Result, 1) & "% " & $Var
EndFunc ;==>Compares
Func dibujar($nX,$nY)
$hand = DllCall($U32,"int", "GetDC", "hwnd",GUICtrlGetHandle($Pic)); 0)
$pen = DllCall($GDI, "int", "CreatePen", "int", 0 , "int",2, "int", $Color)
DllCall($GDI, "int", "SelectObject", "int", $hand[0], "int", $pen[0])
DllCall($GDI, "int", "MoveToEx", "hwnd", $hand[0], "int",$nX, "int", $nY, "int", 0)
DllCall($GDI, "int", "LineTo", "hwnd", $hand[0], "int", $nX, "int", $nY)
EndFunc