Hi,
ich arbeite gerade an einem Programm, dass von einem bestimmten Pixel aus in einem Bild nach außen hin scannt (wie die Zauberstab Funktion in Paint.NET). Allerdings fällt mir keine Alternative zu meiner jetzigen Funktion ein:
Func _ScanColor($iX, $iY, $iW, $iH)
Local $SetterPixelData, $GetterPixelData, $Color, $Red, $Green, $Blue, $RedDiff, $GreenDiff, $BlueDiff
For $row = $iY - 1 To $iY + 1 ; Reihe für Reihe
For $col = $iX - 1 To $iX + 1 ; Spalte für Spalte
If $PixelChecked[($row * $iW) + $col] = '' Then
$SetterPixelData = DllStructCreate("dword", $SetterScan0 + ($row * $Stride) + ($col * 4))
$GetterPixelData = DllStructCreate("dword", $GetterScan0 + ($row * $Stride) + ($col * 4))
$Color = DllStructGetData($GetterPixelData, 1)
$Red = _ColorGetRed($Color)
$Green = _ColorGetGreen($Color)
$Blue = _ColorGetBlue($Color)
$RedDiff = Abs($TargetColor[0] - $Red)
$GreenDiff = Abs($TargetColor[1] - $Green)
$BlueDiff = Abs($TargetColor[2] - $Blue)
If $RedDiff <= $ColorTolerance And $GreenDiff <= $ColorTolerance And $BlueDiff <= $ColorTolerance Then
DllStructSetData($SetterPixelData, 1, BitOR($Blue, BitShift($Green, -8), BitShift($Red, -16)))
$Zaehler += 1
$PixelChecked[($row * $iW) + $col] = True
_ScanColor($col, $row, $iW, $iH)
Else
$PixelChecked[($row * $iW) + $col] = True
EndIf
EndIf
Next
Next
If TimerDiff($OneSecondTimer) >= 1000 Then
ConsoleWrite($Zaehler &" gefärbte Pixel. Letzte Differenzen: " &$RedDiff &" " &$GreenDiff &" " &$BlueDiff &@CRLF)
$OneSecondTimer = TimerInit()
EndIf
EndFunc