Hey,
just had to register to put another way in here :). It is for sure an old old thread, but the "core" will not change so let's put this here
#include <Misc.au3>
#include <ScreenCapture.au3>
#include <GDIPlus.au3>
#include-once
$init=TimerInit()
For $x=1 To 4
For $y=1 To 10
PixelGetColor($x,$y)
Next
Next
Consolewrite("100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y) & @CRLF)
$hDll = DllOpen("gdi32.dll")
$vDC = _PixelGetColor_CreateDC($hDll)
$vRegion = _PixelGetColor_CaptureRegion($vDC, 0,0,320,240,$hDll)
$init=TimerInit()
For $x=1 To 4
For $y=1 To 10
_PixelGetColor_GetPixel($vDC, $x,$y, $hDll)
Next
Next
Consolewrite("100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($x * $y) & @CRLF)
Local $iWidth = 4, $iHeight = 10
_GDIPlus_Startup()
$hBMP = _ScreenCapture_Capture("", 0, 0, 320, 240)
$pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
$tBitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
$tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", DllStructGetData($tBitmapData, "Scan0"))
$init=TimerInit()
For $iX = 0 To $iWidth - 1
For $iY = 0 To $iHeight - 1
Hex(BitAND(DllStructGetData($tPixel, 1, $iY * $iWidth + $iX + 1), 0xFFFFFF), 6)
Next
Next
Consolewrite("100%: " & TimerDiff($init) & @crlf & "Average: " & TimerDiff($init)/($iWidth * $iHeight) & @CRLF)
_GDIPlus_BitmapUnlockBits($pBitmap, $tBitmapData)
_GDIPlus_BitmapDispose($pBitmap)
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
I've also increased the loops to have a better result 🧐
100%: ~79990.1388ms
Average: ~19.3166280608549ms
1060 times faster:
100%: ~75.4109ms
Average: ~0.0182133542622555ms
9452 times faster
100%: ~8.4622ms
Average: ~0.00211755ms