Over a year old, but I was looking into this myself, so here's a working sample for "CompareBytes" applied to two bitmaps, really fast.
Different Bytes = 1432
Difference in % = 0.0476951771915801
Bytes tested = 3002400
Tolerance = 0
Timer = 33.8626
#include <GDIPlus.au3>
_GDIPlus_Startup()
Local $iTimer = TimerInit()
Local $width1, $height1, $stride1, $pbitmap1
Local $Bitmap1 = getbmpdata(@ScriptDir & "\test_1.jpg", $width1, $height1, $stride1, $pbitmap1)
Local $width2, $height2, $stride2, $pbitmap2
Local $Bitmap2 = getbmpdata(@ScriptDir & "\test_2.jpg", $width2, $height2, $stride2, $pbitmap2)
Local $i_Bitmap2_Size = DllStructGetSize($Bitmap2)
Local $iBytesToTest = DllStructGetSize($Bitmap1)
If $i_Bitmap2_Size > $iBytesToTest Then $iBytesToTest = $i_Bitmap2_Size
Local $iTolerance = 0
$iRes = DllCall(@ScriptDir & "\ProSpeed3.0.dll", "long", "CompareBytes", "long", DllStructGetPtr($Bitmap1), "long", DllStructGetPtr($Bitmap2), "long", $iBytesToTest, "long", $iTolerance)
ConsoleWrite("Different Bytes" & @TAB & " = " & $iRes[0] & @CRLF)
; Ergebniss: Long - 0 bei kompletter Übereinstimmung, ansonsten Anzahl verschiedener Bytes.
ConsoleWrite("Difference in %" & @TAB & " = " & $iRes[0] / $iBytesToTest * 100 & @CRLF)
ConsoleWrite("Bytes tested" & @TAB & " = " & $iBytesToTest & @CRLF)
ConsoleWrite("Tolerance" & @TAB & " = " & $iTolerance & @CRLF)
ConsoleWrite("Timer" & @TAB & @TAB & " = " & TimerDiff($iTimer) & @CRLF)
_GDIPlus_ImageDispose($pbitmap1)
_GDIPlus_ImageDispose($pbitmap2)
_GDIPlus_Shutdown()
Func getbmpdata($bmpfile, ByRef $width, ByRef $height, ByRef $stride, ByRef $pbitmap) ;returns a struct with the data of the pixel
; by AndyG
; https://www.autoitscript.com/forum/topic/106815-bitblt-picture-compare-count-difference/?do=findComment&comment=753998
$pbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile)
;_GDIPlus_BitmapLockBits gibt $tagGDIPBITMAPDATA-Struktur zurück
$BitmapData = _GDIPlus_BitmapLockBits($pbitmap, 0, 0, _GDIPlus_ImageGetWidth($pbitmap), _GDIPlus_ImageGetHeight($pbitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB)
If @error Then MsgBox(0, "", "Error locking region " & @error)
$stride = DllStructGetData($BitmapData, "Stride") ;Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.
$width = DllStructGetData($BitmapData, "Width") ;Image width - Number of pixels in one scan line of the bitmap.
$height = DllStructGetData($BitmapData, "Height") ;Image height - Number of scan lines in the bitmap.
;$pixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap
$Scan0 = DllStructGetData($BitmapData, "Scan0") ;Scan0 - Pointer to the first (index 0) scan line of the bitmap.
$pixeldata = DllStructCreate("ubyte[" & (Abs($stride) * ($height)) & "]", $Scan0)
$BMPData = DllStructGetData($pixeldata, 1)
_GDIPlus_BitmapUnlockBits($pbitmap, $BMPData)
; _WinAPI_DeleteObject($pbitmap)
;_GDIPlus_ImageDispose($pBitmap) ;destroys the pixeldatastruct, have to be done at end of the script!
Return $pixeldata
EndFunc ;==>getbmpdata