Func ImgPixelSearch($bmp, ByRef $rx, ByRef $ry, $x = 0, $y = 0, $x1 = @DesktopWidth, $y1 = @DesktopHeight);Viktor1703 kod_start
Local $hImage, $iWidth, $iHeight, $iBitmap, $hBitmap
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($bmp)
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$iBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($iBitmap)
Dim $iMatrix[$iHeight][$iWidth]
For $H = 0 To $iHeight - 1
For $W = 0 To $iWidth - 1
$iMatrix[$H][$W] = '0x' & Hex(_GDIPlus_BitmapGetPixel($hBitmap, $W, $H), 6)
Next
Next
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($iBitmap)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
;Viktor1703 kod_end
;_ArrayDisplay($imatrix)
Dim $lx, $ly, $i, $i1, $img_x, $imh_y
For $img_x = 0 To $iWidth
For $img_y = 0 To $iHeight
If $iMatrix[$img_x][$img_y] <> 0xFFFFFF Then ExitLoop(2) ;мы должны найти непрозрачный пиксель
Next
Next
Local $px
FFSnapShot()
$px = FFNearestPixel(50, 20, $iMatrix[$img_x][$img_y], False, $x, $y, $x1, $y1) ;ищем его cтроку
While Not @error
$px = FFNearestPixel(50, 20, $iMatrix[$img_x][$img_y], False, $x, $y, $x1, $y1) ;ищем его cтроку
If IsArray($px) Then
For $i = $img_x To $iHeight - 1 ;начинаем с места, где нет прозрачности
For $i1 = $img_y To $iWidth - 1
If FFGetPixel($i, $i1) == 0xFFFFFF Then ContinueLoop ;Проверка на прозрачность
If FFGetPixel($px[0] + $i1, $px[1] + $i) <> $iMatrix[$i][$i1] Then ExitLoop(2) ;Если хоть 1 пиксель отличается - прерываем цикл
If ($i1 == $iWidth - 1)And($i == $iHeight - 1) Then ;Если все пиксели совпадают, то мы нашли картинку
$rx = $px[0]
$ry = $px[1]
FFResetExcludedAreas()
return 1
EndIf
Next
Next
FFAddExcludedArea($px[0], $px[1], $px[0], $px[1])
Else
ExitLoop(1)
EndIf
WEnd
FFResetExcludedAreas()
return 0
EndFunc