#include <GDIPlus.au3>
#include <Array.au3>
#include <File.au3>

Global $aPos[0][2]
Global $arr[0][2]
Global $arr2[0][2]

Global Const $I_COLORa = 0x0FF04CEFC ;0 (vor dem FF) wird benötigt, da die Zahl sonst negativ ist)
Global Const $I_COLORb = 0x0FF046AFC
Global Const $I_COLORc = 0x0FF04AAFC
Global Const $I_COLORd = 0x0FF0CFE04
_GDIPlus_Startup()

$hBitmap = _GDIPlus_BitmapCreateFromFile("C:\Users\Kai\Desktop\Werder Tickets\Bilder\Block111.png")

For $y = 0 To _GDIPlus_ImageGetHeight($hBitmap) - 1
   For $x = 0 To _GDIPlus_ImageGetWidth($hBitmap) - 1
	  If _GDIPlus_BitmapGetPixel($hBitmap, $x, $y) = $I_COLORa or _GDIPlus_BitmapGetPixel($hBitmap, $x, $y) = $I_COLORb Or _GDIPlus_BitmapGetPixel($hBitmap, $x, $y) = $I_COLORc Or _GDIPlus_BitmapGetPixel($hBitmap, $x, $y) = $I_COLORd Then
			ReDim $aPos[UBound($aPos) + 1][2]
			$aPos[UBound($aPos) - 1][0] = $x
			$aPos[UBound($aPos) - 1][1] = $y
	  EndIf
   Next
Next

_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
_ArrayAdd ($aPos,'endofarray')

_ArrayDisplay($aPos)
$si = $aPos[0][0]
MsgBox(1, 'hi', UBound($aPos))
Local $a=0
Local $b=0
Local $c=0
Local $d=1

;Falls keine Pixel gefunden werden wird mit dieser Bedingung geskippt!

if ubound($aPos) = 1 then
	  MsgBox(0, 'Damn', 'Keine Plätze im Block')
Else

;Erste Abfrage für Pixel nebeneinander

   Do
	  If $aPos[$a][$b] = $aPos[$a+1][$b] -1 Then
		 $a = $a+1
	  Else
		 ReDim $arr[UBound($arr) + 1][2]
		 $arr[UBound($arr) - 1][0] = $aPos[$a][$b]
		 $arr[UBound($arr) - 1][1] = $aPos[$a][$b]
		 MsgBox(1, 'hi', $a)
		 $a = $a+1
	  EndIf
   Until $a=UBound($aPos)-1

   _ArrayAdd ($arr, 'endofarray')

;Zweite Abfrage für Pixel untereinander

   Do
	  If $arr[$c][$d] = $arr[$c+1][$d] Or $arr[$c][$d] = $arr[$c+1][$d]-10 or $arr[$c][$d] = $arr[$c+1][$d]+10 Then
		 $c = $c+1
	  Else
		 ReDim $arr2[UBound($arr2) + 1][2]
		 $arr2[UBound($arr2) - 1][0] = $arr[$c][$d]
		 $arr2[UBound($arr2) - 1][1] = $arr[$c][$d]
		 MsgBox(1, 'hi', $c)
		 $c = $c+1
	  EndIf
   Until $c=UBound($arr)-1

   MsgBox(1, 'hi', 'Du geiler Macker')

;$arr enthält nun einen Pixel eines freien Platzes

   _ArrayDisplay($arr2)
EndIf

