Bild in GUI darstellen und Farbe ersetzen

  • Also ich möchte eine GUI haben mit einem Bild darin, aber das ist nicht das problem

    Unswar ist es eine Bitmap welches ein Pink enthält , welches aber volständig ersetzt werden soll

    Also GUI nach der Farbe(0xff00ff) durchsuchen und mit einen anderen ersetzen

    WElche GDI+ Befehle brauch ich alles dafür ?

  • das geht mit _GDIPlus_GraphicsFillPolygon
    du musst mit Pixelsearch den gui nach dem zu Löschendem hintergrund absuchen lassen (PINK "FARBCODE") die Positionen
    dan in einem Array speichern und Anschliessend mit_GDIPlus_GraphicsFillPolygon diese Positionen im
    Gui übermalen lassen

  • Bin ja kein AutoiT Anfänger :P

    Nur ich steig jetzt zum ersten Mal in GDI+ ein :D

    Ich schau mir dein GDI+ Paint ma an , denn mir der vorherigen Idee gehts nicht

    Irgendwie raff ich des nich 8|

    Also habe folgendes vor :

    GUI mit Bild erstellen

    Alle Stellen , welche den Farbwert 0xff00ff haben mit einer Farbe übermalen

    Natürlich wäre es besser wenn das direkt aus einer Bitmap heraus geht :P

    Würde mir jemand nen kleines Bsp Skript basteln ?(

    Einmal editiert, zuletzt von Aldi (8. April 2010 um 14:04)

  • Ein kleines Beispiel? Ich versuch's. ^^

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <GUIConstants.au3>

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

    _GDIPlus_Startup()

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

    $hBitmap = _GDIPlus_BitmapCreateFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg;*.png;*.bmp)", 3))
    $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    $iHeight = _GDIPlus_ImageGetHeight($hBitmap)

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

    MsgBox(64, "Farbe", "Zu suchende Farbe auswählen")
    $iSearchColor = StringTrimLeft(_ChooseColor(2), 2)
    MsgBox(64, "Farbe", "Füllfarbe auswählen")
    $iFillColor = StringTrimLeft(_ChooseColor(2), 2)

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

    For $iY = 0 To $iHeight
    For $iX = 0 To $iWidth
    If _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) = "0xFF" & $iSearchColor Then _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, "0xFF" & $iFillColor)
    Next
    Next

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

    _GDIPlus_ImageSaveToFile($hBitmap, FileSaveDialog("Bild speichern unter", @ScriptDir, "(*.png)", 18) & ".png")

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_BitmapGetPixel
    ; Description ...: Gets the color of a specified pixel in this bitmap
    ; Syntax.........: _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
    ; Parameters ....: $hBitmap - Pointer to the Bitmap object
    ; $iX - The X coordinate of the pixel
    ; $iY - The Y coordinate of the pixel
    ; Return values .: Success - Returns the pixel color of the bitmap
    ; Failure - 0 and either:
    ; |@error and @extended are set if DllCall failed
    ; |$GDIP_STATUS contains a non zero value specifying the error code
    ; Remarks .......: None
    ; Related .......: _GDIPlus_BitmapSetPixel
    ; Link ..........; @@MsdnLink@@ GdipBitmapGetPixel
    ; Example .......; Yes
    ; ===============================================================================================================================
    Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "uint*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[4]
    EndFunc ;==>_GDIPlus_BitmapGetPixel

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_BitmapSetPixel
    ; Description ...: Sets the color of a specified pixel in this bitmap
    ; Syntax.........: _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB)
    ; Parameters ....: $hBitmap - Pointer to the Bitmap object
    ; $iX - The X coordinate of the pixel
    ; $iY - The Y coordinate of the pixel
    ; $iARGB - The new color of the pixel
    ; Return values .: Success - True
    ; Failure - False and either:
    ; |@error and @extended are set if DllCall failed
    ; |$GDIP_STATUS contains a non zero value specifying the error code
    ; Remarks .......: None
    ; Related .......: _GDIPlus_BitmapGetPixel
    ; Link ..........; @@MsdnLink@@ GdipBitmapSetPixel
    ; Example .......; Yes
    ; ===============================================================================================================================
    Func _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapSetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "uint", $iARGB)

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

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
    EndFunc ;==>_GDIPlus_BitmapSetPixel

    [/autoit]