Hi,
habe aktuell folgendes kleines Script:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
OnAutoItExitRegister("_end")
[/autoit] [autoit][/autoit] [autoit]$chipsetpfad = FileOpenDialog("Chipset", @ScriptDir & "\", "Bilder (*.png)", 1)
[/autoit] [autoit][/autoit] [autoit]$newchipset = GUICreate("Neues Chipset", 480, 256)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "getPixelcolor")
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$chipset = _GDIPlus_ImageLoadFromFile($chipsetpfad)
$graphic = _GDIPlus_GraphicsCreateFromHWND($newchipset)
_GDIPlus_GraphicsDrawImage($graphic, $chipset, 0, 0)
While 1
Sleep(100)
WEnd
Func getPixelcolor()
$pos = MouseGetPos()
$pix = PixelGetColor($pos[0], $pos[1])
$sMsgText = StringFormat("Der hexadezimale Wert der Farbe ist: %#06x\t", $pix)
MsgBox(0, "PixelGetColor", $sMsgText)
EndFunc ;==>getPixelcolor
Func CLOSEClicked()
Exit
EndFunc ;==>CLOSEClicked
Func _end()
_GDIPlus_GraphicsDispose($graphic)
_GDIPlus_ImageDispose($chipset)
_GDIPlus_Shutdown()
EndFunc ;==>_end
In der Funktion getPixelcolor() wird der Hexwert der Farbe des Pixel an der aktuellen Mausposition ermittelt. Nun möchte ich diese Farbe im ganzen Bild transparent machen und ale neues PNG speichern. Hoffe es kann mir jemand sagen wie ich das mache.
Edit: Habs hinbekommen:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
Opt("MouseCoordMode", 2)
OnAutoItExitRegister("_end")
[/autoit] [autoit][/autoit] [autoit]$chipsetpfad = FileOpenDialog("Chipset", @ScriptDir & "\", "Bilder (*.png)", 1)
[/autoit] [autoit][/autoit] [autoit]$newchipset = GUICreate("Neues Chipset", 480, 256)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "getPixelcolor")
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$chipset = _GDIPlus_ImageLoadFromFile($chipsetpfad)
$graphic = _GDIPlus_GraphicsCreateFromHWND($newchipset)
_GDIPlus_GraphicsDrawImage($graphic, $chipset, 0, 0)
While 1
Sleep(100)
WEnd
Func getPixelcolor()
$pos = MouseGetPos()
$pix = _GDIPlus_BitmapGetPixel($chipset, $pos[0], $pos[1])
For $iY = 0 To 256
For $iX = 0 To 480
If _GDIPlus_BitmapGetPixel($chipset, $iX, $iY) = $pix Then
_GDIPlus_BitmapSetPixel($chipset, $iX, $iY, "00000000")
EndIf
Next
Next
MsgBox(0,"","fertig")
_GDIPlus_GraphicsClear($graphic, 0x00000000)
_GDIPlus_GraphicsDrawImage($graphic, $chipset, 0, 0)
_GDIPlus_ImageSaveToFile($chipset, FileSaveDialog("Bild speichern unter", @ScriptDir, "(*.png)", 18) & ".png")
EndFunc ;==>getPixelcolor
; #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)
If @error Then Return SetError(@error, @extended, 0)
$GDIP_STATUS = $aResult[0]
Return $aResult[4]
EndFunc ;==>_GDIPlus_BitmapGetPixel
; #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)
If @error Then Return SetError(@error, @extended, False)
$GDIP_STATUS = $aResult[0]
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_BitmapSetPixel
Func CLOSEClicked()
Exit
EndFunc ;==>CLOSEClicked
Func _end()
_GDIPlus_GraphicsDispose($graphic)
_GDIPlus_ImageDispose($chipset)
_GDIPlus_Shutdown()
EndFunc ;==>_end