Bild Transparent machen

  • Heyho leute,

    Ich habe jetzt schon wirkle viel gegoogelt.
    aber ich bekomme es einfach nicht hin ein bild mit transparetz zu machen in einer gui.

    Aus der hilfe konnte ich was entnehmen.
    "Um ein transparentes Bild zu erzeugen, ist es erforderlich, dass das GUI-Fenster mit dem erweiterten Stil WS_EX_LAYERED erzeugt wird. Das oberste linke Pixel wird hierbei als "transparente Farbe" benutzt. Werden mehrere Bilder erzeugt, bestimmt das letzte Bild die "transparente Farbe"."

    aber irgendwie klapp das nicht.

    Ich hab das schon mit einem normalen jpg probiert wo die ecke oben links weiß ist , aber es geht nicht.
    mit einer "gif" grafik hab ich es auch schon probiert geht immer noch ne.

    Und ich habe es sogra mit GDI+ probiert aber da habe ich das problem das, dass spiel dann so richtig abkackt mit "wollen sie an microsoft senden".

    hier mein script vor den ganzen versuchen ihr muss aber noch die bilder im anhang runterladen

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #Include <File.au3>
    #include <Array.au3>
    #include <Misc.au3>
    #include "GIFAnimation.au3"
    #include <GDIPlus.au3>

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

    Global $avArray[100000],$avArray2[100000],$blaa

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

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

    $dll = DllOpen("user32.dll")

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

    $i = 1
    $ii = 1
    $iii= 3
    $size=20
    $left=$size
    $top=10
    $line = 2
    $leben = 10

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

    $1234="wall"

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

    FileOpen ("world\"&$1234&".txt")
    $lines= _FileCountLines("world\"&$1234&".txt")
    $GUI = GUICreate ("das ist ein test",1600,800,-1,-1)

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

    $0 = FileReadLine("world\"&$1234&".txt",1)
    $0 = StringSplit ($0,",")

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

    $top1=$top

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

    $wall = FileReadLine("world\"&$1234&".txt",$line)
    $wall = StringSplit ($wall,"")
    $wallnumber=UBound ($wall)

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

    While 1
    if $wallnumber > $i then
    $var = IniReadSection("ini\"& $1234&".ini", $wall[$i])

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

    If @error Then
    $1 = Random(1,$0[0],1)
    GUICtrlCreatePic ("images\"& $0[$1],$left,$top1,$size,$size)
    $avArray[$iii] = 0
    $avArray2[$iii] = 0
    Else
    if $var[2][1] == 1 then
    $1 = Random(1,$0[0],1)
    GUICtrlCreatePic ("images\"& $0[$1],$left,$top1,$size,$size)
    $avArray[$iii] =0
    $avArray2[$iii] =0
    $lefts=$left


    $tops=$top1
    $spieler=$var[1][1]

    Else

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

    GUICtrlCreatePic ("images\"& $var[1][1],$left,$top1,$size,$size)
    $avArray[$iii] = $var[3][1]
    $avArray2[$iii] = $var[4][1]
    EndIf
    EndIf

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

    $i+=1
    $left+=$size
    $iii+=1
    else
    $line +=1
    if $line <= $lines then

    $wall = FileReadLine("world\"&$1234&".txt",$line)
    $wall = StringSplit ($wall,"")

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

    $wallnumber=UBound ($wall)
    $i=1
    $top1 +=$size
    $left=$size
    Else
    FileClose ("world\"&$1234&".txt")
    ExitLoop
    EndIf

    EndIf
    WEnd
    $spieler = GUICtrlCreatePic ("images\"& $spieler,$lefts,$tops,$size,$size)
    $label = GUICtrlCreateLabel ("Leben:"& $leben,1200,10)
    GUISetState(@SW_SHOW)

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

    While 1
    If _IsPressed("25", $dll) Then
    left()
    EndIf
    If _IsPressed("26", $dll) Then
    up()
    EndIf
    If _IsPressed("27", $dll) Then
    right()
    EndIf
    If _IsPressed("28", $dll) Then
    down()
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch
    WEnd

    func main()
    Exit
    EndFunc

    func left()
    $lefts-=$size
    $ControlID = _GetControlByPos($gui, $lefts,$tops)
    if $avArray[$ControlID] == 0 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    ElseIf $avArray[$ControlID] == 3 then

    _newworld ($ControlID)

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

    ElseIf $avArray[$ControlID] == 4 then
    $leben -= 1
    if $leben == 0 Then
    MsgBox (0,0,"GAME OVER :-)")
    Exit
    EndIf
    GUICtrlSetData ($label,"Leben:"&$leben)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    $pic = GUICtrlCreatePic ("1.jpg",0,0,1600,800)
    Sleep (20)
    GUICtrlDelete ($pic)

    ElseIf $avArray[$ControlID] == 5 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    if Random (0,10,1) = 1 Then
    _pokemon()

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

    EndIf
    ElseIf $avArray[$ControlID] == 10 then
    $datei = FileOpen($avArray2[$ControlID] & ".txt", 0)
    MsgBox (0,0,FileRead("msg\"&$avArray2[$ControlID]) )
    $lefts+=$size
    Else
    $lefts+=$size
    EndIf
    EndFunc

    func right()
    $lefts+=$size
    $ControlID = _GetControlByPos($gui, $lefts,$tops)
    if $avArray[$ControlID] == 0 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    ElseIf $avArray[$ControlID] == 3 then

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

    _newworld ($ControlID)

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

    ElseIf $avArray[$ControlID] == 4 then
    $leben -= 1
    if $leben == 0 Then
    MsgBox (0,0,"GAME OVER :-)")
    Exit
    EndIf
    GUICtrlSetData ($label,"Leben:"&$leben)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    $pic = GUICtrlCreatePic ("1.jpg",0,0,1600,800)
    Sleep (20)
    GUICtrlDelete ($pic)

    ElseIf $avArray[$ControlID] == 5 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    if Random (0,10,1) = 1 Then
    _pokemon()
    ;MsgBox (0,0,"Hier wehre jetzt ein Pokemon gekommen")

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

    EndIf
    ElseIf $avArray[$ControlID] == 10 then
    $datei = FileOpen($avArray2[$ControlID] & ".txt", 0)
    MsgBox (0,0,FileRead("msg\"&$avArray2[$ControlID]) )
    $lefts-=$size
    Else
    $lefts-=$size
    EndIf
    EndFunc

    func up()
    $tops-=$size
    $ControlID = _GetControlByPos($gui, $lefts,$tops)
    if $avArray[$ControlID] == 0 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    ElseIf $avArray[$ControlID] == 3 then

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

    _newworld ($ControlID)
    ElseIf $avArray[$ControlID] == 4 then
    $leben -= 1
    if $leben == 0 Then
    MsgBox (0,0,"GAME OVER :-)")
    Exit
    EndIf
    GUICtrlSetData ($label,"Leben:"&$leben)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    $pic = GUICtrlCreatePic ("1.jpg",0,0,1600,800)
    Sleep (20)
    GUICtrlDelete ($pic)
    ElseIf $avArray[$ControlID] == 5 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    if Random (0,10,1) = 1 Then
    _pokemon()
    ;MsgBox (0,0,"Hier wehre jetzt ein Pokemon gekommen")
    EndIf
    ElseIf $avArray[$ControlID] == 10 then
    $datei = FileOpen($avArray2[$ControlID] & ".txt", 0)
    MsgBox (0,0,FileRead("msg\"&$avArray2[$ControlID]) )
    $tops+=$size
    else
    $tops+=$size
    EndIf
    EndFunc

    func down()
    $tops+=$size
    $ControlID = _GetControlByPos($gui, $lefts,$tops)
    if $avArray[$ControlID] == 0 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    ElseIf $avArray[$ControlID] == 3 then

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

    _newworld ($ControlID)
    ElseIf $avArray[$ControlID] == 4 then
    $leben -= 1
    if $leben == 0 Then
    MsgBox (0,0,"GAME OVER :-)")
    Exit
    EndIf
    GUICtrlSetData ($label,"Leben:"&$leben)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    $pic = GUICtrlCreatePic ("1.jpg",0,0,1600,800)
    Sleep (20)
    GUICtrlDelete ($pic)
    ElseIf $avArray[$ControlID] == 5 then
    Sleep (50)
    GUICtrlSetPos ( $spieler, $lefts, $tops)
    if Random (0,10,1) = 1 Then
    _pokemon()
    ;MsgBox (0,0,"Hier wehre jetzt ein Pokemon gekommen")
    EndIf

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

    ElseIf $avArray[$ControlID] == 10 then
    $datei = FileOpen($avArray2[$ControlID] & ".txt", 0)
    MsgBox (0,0,FileRead("msg\"&$avArray2[$ControlID]) )
    $tops-=$size
    else
    $tops-=$size
    EndIf
    EndFunc

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

    Func _GetControlByPos($hGui, $iX, $iY)
    For $i = 1 To 100000
    $aPos = ControlGetPos($GUI, "", $i)
    If IsArray($aPos) And $iX = $aPos[0] And $iY = $aPos[1] Then Return $i
    Next
    Return -1
    EndFunc

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

    Func _newworld ($ControlID)

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

    GUIDelete ($GUI)

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

    $i = 1
    $ii = 1
    $iii= 3

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

    $left=$size
    $top=10
    $line = 2
    $blaa = $ControlID
    $1234 = $avArray2[$ControlID]

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

    FileOpen ("world\"&$1234&".txt")
    $lines= _FileCountLines("world\"&$1234&".txt")
    $GUI = GUICreate ("das ist ein test",1600,800,-1,-1)

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

    $0 = FileReadLine("world\"&$1234&".txt",1)
    $0 = StringSplit ($0,",")

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

    $top1=$top

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

    $wall = FileReadLine("world\"&$1234&".txt",$line)
    $wall = StringSplit ($wall,"")
    $wallnumber=UBound ($wall)

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

    While 1
    if $wallnumber > $i then
    $var = IniReadSection("ini\"& $1234&".ini", $wall[$i])

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

    If @error Then
    $1 = Random(1,$0[0],1)
    GUICtrlCreatePic ("images\"& $0[$1],$left,$top1,$size,$size)
    $avArray[$iii] = 0
    $avArray2[$iii] = 0
    Else
    if $var[2][1] == 1 then
    $1 = Random(1,$0[0],1)
    GUICtrlCreatePic ("images\"& $0[$1],$left,$top1,$size,$size)
    $avArray[$iii] =0
    $avArray2[$iii] =0
    $lefts=$left


    $tops=$top1
    $spieler=$var[1][1]

    Else

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

    GUICtrlCreatePic ("images\"& $var[1][1],$left,$top1,$size,$size)
    $avArray[$iii] = $var[3][1]
    $avArray2[$iii] = $var[4][1]
    EndIf
    EndIf

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

    $i+=1
    $left+=$size
    $iii+=1
    else
    $line +=1
    if $line <= $lines then

    $wall = FileReadLine("world\"&$1234&".txt",$line)
    $wall = StringSplit ($wall,"")

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

    $wallnumber=UBound ($wall)
    $i=1
    $top1 +=$size
    $left=$size
    Else
    FileClose ("world\"&$1234&".txt")
    ExitLoop
    EndIf

    EndIf
    WEnd
    $spieler = GUICtrlCreatePic ("images\"& $spieler,$lefts,$tops,$size,$size)
    $label = GUICtrlCreateLabel ("Leben:"& $leben,1200,10)
    GUISetState(@SW_SHOW)
    EndFunc

    Func _pokemon ()

    $fulla=0
    $fullb=0
    $ka=600
    $kb=400
    $kc=0
    $kd=0
    $kea=$ka
    $keb=$kb
    $sizex=$size
    GUIDelete ($GUI)
    $GUI = GUICreate ("",600,400,-1,-1)
    while 1
    $fullao=$fulla
    $fullbo=$fullb
    GUISetState(@SW_SHOW)
    while $fulla<=$ka and $fullb<=$kb
    $blink=GUICtrlCreatePic("images\schwarz.jpg", $fulla, $fullb, $size, $size)
    if $fulla>=$kea and $fullb<=$keb Then
    $fullb=$fullb+$size
    Else
    $fulla=$fulla+$size
    EndIf
    WEnd
    $fullb=$fullb-$size
    while $fulla>=$kc and $fullb>=$kd
    $blink=GUICtrlCreatePic("images\schwarz.jpg", $fulla, $fullb, $size, $size)
    if $fulla<$size Then
    $fullb=$fullb-$size
    Else
    $fulla=$fulla-$size
    EndIf
    WEnd

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

    $fulla=$fullao+$size
    $fullb=$fullbo+$size
    $ka=$ka-$size
    $kb=$kb-$size
    $kc=$kc+$size
    $kd=$kd+$size
    $sizex=$sizex+$size

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

    $fullao=$fulla
    $fullbo=$fullb
    GUISetState(@SW_SHOW)
    while $fulla<=$ka and $fullb<=$kb
    $blink=GUICtrlCreatePic("images\schwarz.jpg", $fulla, $fullb, $size, $size)
    if $fulla>=$ka and $fullb<=$kb Then
    $fullb=$fullb+$size
    Else
    $fulla=$fulla+$size
    EndIf
    WEnd
    $fullb=$fullb-$size
    while $fulla>=$kc and $fullb>=$kd
    $blink=GUICtrlCreatePic("images\schwarz.jpg", $fulla, $fullb, $size, $size)
    if $fulla<$sizex Then
    $fullb=$fullb-$size
    Else
    $fulla=$fulla-$size
    EndIf
    WEnd
    if $fulla>=$ka/2 Then
    ExitLoop
    EndIf
    WEnd
    $size=20
    msgbox(4096, "Pokemon", "Immer noch keine Pokemon")
    Exit
    _newworld($blaa)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Hier mal ein Mustercode (Bild ist binär eingebunden).

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>

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

    #region - Transparente Bild-Datei
    OnAutoItExitRegister("_DelBinaryTempFiles")
    ; String mit den Binärdaten von: config_tool1.gif (48x48)
    Local $bPict = "0x47494638396130003000F70000000000153E0C1F5B0A3B5F382668072A700E357C1833672E3975383D7C31437D1C4A7C2449484950524F5153515958576A6A696F6D6A7173717574737B7A777D7D7D7E7E7E3E820D3E82163E84233E813E43820C4880164E83154B8A114A8A1851871B538D1457921A4186234789224A8A2C4A8E2F498E314F92254A90314B91324E93354A9039528F2250803253962052972B5A992652973754973D54983B5A9D345D9F33619F2967A22960A13B6BA7326AA53D6CA93B72AA2D70AA3F78AE3C49934C5C89455895525E935F57A55C5DA163648C4F6C985C6991687298677B9D6A61A14065A44A69A64461A3506CA85169AA5C76B04C7CB5457FB64972B05477B15779B75762A66966A36867AE6D6EAC7773B36B7EB8667DB86D7DBA747EBC7079B8797EBD8686BA4781B85F86BB668BB96F87B57281BF7D8AB8718BC1528BC66B8CC77C91C7749AD27D8384838585858686868989898C8C8C8E8E8E9090909292929494949596959696969799989898989A9A9A9C9B9B9E9E9E9F9F9F80AD858DA782A0A0A0A3A3A3A5A5A1A6A6A6A5AEA5A8A4A2A9A9A9AAAAAAACACACAEAEAEAFAFAFB0B0AFB0B0B0B1B1B1B2B2B2B3B3B4B2B4B2B4B4B4B6B6B6B7B7B7B8B8B8BABABABCBCBCBEBEBEBFBFBF85C18086C3858FC98B92CA8291CD8797CF8890CB9092CE9496CF9094CF969DC59895D1999FD6929CD6959EC9A195D0A19BD2A99FD9A39ED9A59FDAA69ED9A89FD9A9A0C698A0DAA6A4DDA2A7DDA7A1DAA8A4DEAAA4DDACA7DFAFA7DEB6A8D9B2ABDCB8B4D2A9B5DDBDA7E0AFAAE2ACACE3A8A8E1B1A9E2B0ABE2B1AEE6B6AFE7BBB1E8B9B0E9BDB0E8BFB2EAC1B4EDC7B7EFC8B8F0CBC0C0C0C1C1C1C2C2C2C4C4C4C6C6C6C7C7C7C8C8C8C9C9C9CACACACBCBCBCCCCCCCDCDCDCECECECFCFCFD0D0D0D2D2D2D4D4D4D6D6D6D8D8D8D9D9D9DADADADBDBDBDCDCDCDEDEDEC1F8D3E0E0E0E1E1E1E3E3E3E4E4E4E5E5E5E6E6E6E7E7E7E8E8E8E9E9E9EAEAEAEBEBEBECECECEDEDEDEEEEEEF0F0F0F1F1F1F2F2F2F3F3F3F4F4F4F5F5F5F6F6F6F7F7F7F8F8F8F9F9F9FAFAFAFEFEFE00000021F904010000FF002C00000000300030000008FF00FF091C48B0A0C18308132A5CC8B0A1C3871023E6C2A52BA24584A4C0B852B64CD5C58F03596C29658C5C3254202F1EC9E0E44C2C5AB6BEA42CE86E1E3F85490AA880B269950D644F66FECB362F5F3E81D5C021146060058A519EA8043313F11BC14CEEE0C18B27D05ABD840432C060D2CA8AA83511A7D5FB3AE91CBAB7021BCDF39730C885142FBCD4E241AC0AC46AE9D6B15B67EE5AB36802FDE03B9A5001061931429D8A320C8DC345DDC0651237AE5CB9698BFE49D3C6AEDDC20D236A3469A5A6D3278789BA4162000193BB76EACE9513C779DC42251E4EDCE8D24B8AB0310D9F79E36328C28470F5EC2DD687AF9E3C862E3ED0C0014AD6946265188AFFBBD4C0CD206ADBBA9943A7AEDDBB78A619722091C347AC366C4CED52A8ED5B9E070E48308E37DC4C438D36E979C38C432198A00317C0A4310B190A89F3CD368C50F0C8371C7AA38D33975442C843468830430F9CF822C62DB020840D37FD11D88D37DE7C43A3338158B4400B4BFCC0CA2FC768715033CFE8F1467F1C7E93CD227EA4D441093B68F24A2A57185449338854924834DE54D2A450FF000242024260514416053D72C922975CF28C34601A848006401011062F032D524925CF3833CD24712284C40143FC2190229438630D357F069A5000031412C92395BCB8CD358E2E74879B977C234E38DA64BA50227268830D3AE76C23AA429648E32587DCACFC9A1035D57C53CF2592C42AEB41DC5473CE3EFBDCB3C735AAEE4A1037D4C0D34F3FFC78F34F1C4A192B1036D3CCB3EC3EDD0CB48755C642238D3C46D9A3EB40958C9BA9246FC233CF3CF2845A501DEE664A0734D1B4D7CE3AD8200447B68ED611CD33E59863CE38D328D48733810AD2278DDE7483F0429838026625CC30A3CDC5D83CBC9005D9CCE4672597482372348839240735203DB34D36CE34E332337042A44D342847844D378910E2CD35965812CD881065E288251685537323E058F20CD010C1D16AC11095339024E25073C8477674233544E3440BCD378980040722F46CED901FE054534D377ACC0407AE11CD81871C15486BF7DD78DB1D10003B"
    Global $sPictFile = @ScriptDir & "\config_tool.gif"
    Local $hFileOut = FileOpen($sPictFile, 2+8+16)
    FileWrite($hFileOut, Binary($bPict))
    FileClose($hFileOut)

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

    Func _DelBinaryTempFiles()
    FileDelete($sPictFile)
    EndFunc
    #endregion

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

    $guiMain = GUICreate('Main', 400, 300)
    ; == Ein Child erstellen in der Größe des Pictures
    $guiChild = GUICreate("Child", 48, 48, 176, 126, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $guiMain)
    ; == darauf platzieren wir das transparente Picture
    GUICtrlCreatePic($sPictFile, 0, 0, 48, 48)
    GUISetState(@SW_SHOW, $guiChild)
    GUISetState(@SW_SHOW, $guiMain)

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

    $t = TimerInit()
    While 1
    Switch GUIGetMsg()
    Case -3
    Exit
    EndSwitch
    If TimerDiff($t) >= 3000 Then GUISetBkColor(0xFFFFAA, $guiMain)
    WEnd

    [/autoit]