Bild "abpauschen"

  • Hallo, ich habe mal ein Script erstellt, welches zuersteinmal die Pixel von einem Bereich in ein Array liest. Schön und gut, funktioniert soweit.
    Jetzt kam ich auf die schöne Idee, AutoIt mal ein Vorgegebenes Bild, in Paint nachzumalen via MouseClick und dem Pinsel. Klappt soweit auch.
    Jedoch ist die Funktion durch das MouseClick sehr lahm geworden.
    Hatte auch Probiert es mit GDI auf den Desktop zu malen, jedoch ist jedesmal mein PC abgeschmiert. Kann vielleicht daran gelegen haben, dass er bei meinem Bild c.a. 16000 pixel einzelnt nacheinander mit GDI versucht hat zu malen o.O.

    Erstmal mein Code und 2 Bilder meines 1. Abpauschversuches:

    Spoiler anzeigen
    [autoit]

    HotKeySet("{ESC}","_exit")

    [/autoit] [autoit][/autoit] [autoit]

    Local $NumofPixelsHigh = 378;you will need to use the window info tool to establish size of image you want to use.
    Local $NumofPixelsWide = 367;Same as above
    Local $Coord[2] = [880, 44] ;Top left corner of image
    Local $tCoord[2] = [882, 475]
    Global $Target[$NumofPixelsHigh][$NumofPixelsWide], $Current[$NumofPixelsHigh][$NumofPixelsWide]
    Global $Y, $X, $B = 0, $hDC, $obj_orig, $hPen, $hDC
    $oFile = FileOpen(@ScriptDir & "\test.txt", 1)

    [/autoit] [autoit][/autoit] [autoit]

    For $Y = 0 To $NumofPixelsHigh - 1
    For $X = 0 To $NumofPixelsWide - 1
    $Target[$Y][$X] = PixelGetColor($Coord[0] + $X, $Coord[1] + $Y)
    If $Target[$Y][$X] = "0x000000" Then
    $Target[$Y][$X] = 1
    MouseClick("left", $tCoord[0] + $X, $tCoord[1] + $Y,1,0)
    Else
    $Target[$Y][$X] = 0
    EndIf;This gets the color value, then checks to see if it is black, if it is we assign a 1 value, if not we assign a 0 value.
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;~ For $x = 0 to UBound($Target,1)-1
    ;~ For $y = 0 to UBound($Target,2)-1
    ;~ If ( $Target[$x][$y] == $aSearchArray[0][0] ) Then ;; Just finds a starting point for the correct match, then later checks if this is correct
    ;~ If ( _IsCorrect($x,$y) == 1 ) Then
    ;~ MsgBox(0x40,"Au3 Test", "Correct match found at position [" & $x & "," & $y & "].")
    ;~ Exit
    ;~ EndIf
    ;~ EndIf
    ;~ Next
    ;~ Next

    [/autoit] [autoit][/autoit] [autoit]

    Func _IsCorrect($n, $m) ; This is helper function which goes through the global array to see if this is the correct match we are looking for. Returns 1 for succes.
    $k = $n + UBound($aSearchArray, 1) - 1
    $l = $m + UBound($aSearchArray, 2) - 1
    If ($k > UBound($Target, 1)) Then Return 0 ; goes outside the boundaries, so we can be sure this isn't correct
    If ($l > UBound($Target, 2)) Then Return 0

    [/autoit] [autoit][/autoit] [autoit]

    For $X = $n To $k
    For $Y = $m To $l
    If ($Target[$X][$Y] <> $aSearchArray[$X - $n][$Y - $m]) Then
    Return 0
    EndIf
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Return 1
    EndFunc ;==>_IsCorrect

    [/autoit] [autoit][/autoit] [autoit]

    Func _exit()
    Exit
    EndFunc

    [/autoit]

    Während des Malens:
    autoit.de/wcf/attachment/4877/

    Fertig mit dem Malen
    autoit.de/wcf/attachment/4878/

    So, meine Frage ist, kann man diesen Vorgang mit GDI machen ? Ohne das der PC abschmiert ?^^ Wenn ja, kann mir wer nen Tip geben wie ?