1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. eukalyptus

Beiträge von eukalyptus

  • GDI+ Paint

    • eukalyptus
    • 28. März 2010 um 16:59

    Für Effekte solltest du mal nach Colormatrix googlen

    Hier ein Beispielscript:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Opt("TrayIconDebug",1)

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

    $sFile = FileOpenDialog("Wähle Bilddatei",@ScriptDir,"(*.jpg;*.bmp;*.png;*.gif)")

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    $iH = _GDIPlus_ImageGetHeight($hImage)*96/_GDIPlus_ImageGetHorizontalResolution($hImage)
    $iW = _GDIPlus_ImageGetWidth($hImage)*96/_GDIPlus_ImageGetVerticalResolution($hImage)

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

    $hGui = GUICreate("Test", $iW, $iH)
    GUISetState()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBitmap=_GDIPlus_BitmapCreateFromGraphics($iW, $iH,$hGraphics)
    $hContext=_GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImage($hContext, $hImage, 0, 0)
    GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")

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

    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Original" & @LF & "Drücke Ok")

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

    $hImage1 = _ColorMatrix($hImage,"0.30,0.30,0.30,0,0|0.59,0.59,0.59,0,0|0.11,0.11,0.11,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Greyscale" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    $hImage1 = _ColorMatrix($hImage,"-1,0,0,0,0|0,-1,0,0,0|0,0,-1,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Invert" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    $hImage1 = _ColorMatrix($hImage,"1,0,0,0,0|0,0,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Red" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    $hImage1 = _ColorMatrix($hImage,"0,0,0,0,0|0,1,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Green" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    $hImage1 = _ColorMatrix($hImage,"0,0,0,0,0|0,0,0,0,0|0,0,1,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Blue" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    $hImage1 = _ColorMatrix($hImage,"1,1,0,0,0|0,0,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
    _GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
    _WinAPI_RedrawWindow($hGui,0,0,5)
    MsgBox(0, "", "Yellow" & @LF & "Drücke Ok")
    _GDIPlus_ImageDispose($hImage1)

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

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()

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

    Func _ColorMatrix($hImage,$sMatrix)
    Local $hGraphics=_GDIPlus_ImageGetGraphicsContext($hImage)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    _GDIPlus_GraphicsDispose($hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]")
    Local $aMatrix=StringSplit(StringReplace($sMatrix,"|",","),","), $iCnt=0
    For $i=1 To 5
    For $j=1 To 5
    $iCnt+=1
    DllStructSetData($tColorMatrix, $i, $aMatrix[$iCnt], $j)
    Next
    Next
    Local $hImgAttrib = _GDIPlus_ImageAttributesCreate()
    _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, 1, DllStructGetPtr($tColorMatrix))
    _GDIPlus_GraphicsDrawImageRectRectEx($hContext, $hImage, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, 2, $hImgAttrib)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_ImageAttributesDispose($hImgAttrib)
    Return $hBitmap
    EndFunc ;==>_GreyScale

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

    Func _WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return True
    EndFunc

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

    Func _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, $iColorAdjustType, $pColorMatrix = 0, $pGrayMatrix = 0, $iColorMatrixFlags = 0)
    Local $fEnable = 1, $aResult = DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", $iColorAdjustType, _
    "int", $fEnable, "ptr", $pColorMatrix, "ptr", $pGrayMatrix, "int", $iColorMatrixFlags)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_ImageAttributesSetColorMatrix

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

    ;;Creates ImageAttributes object
    Func _GDIPlus_ImageAttributesCreate()
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
    Return SetError($aResult[0], 0, $aResult[1])
    EndFunc ;==>_GDIPlus_ImageAttributesCreate

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

    ;;Deletes ImageAttributes object
    Func _GDIPlus_ImageAttributesDispose($hImgAttrib)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_ImageAttributesDispose

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

    ;; _GDIPlus_GraphicsDrawImageRectRectEx()
    ;; Same as _GDIPlus_GraphicsDrawImageRectRect(), but adds 1 optional parameter - $hImgAttrib (handle to ImageAttributes object)
    Func _GDIPlus_GraphicsDrawImageRectRectEx($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth, $iSrcHeight, $iDstX, $iDstY, $iDstWidth, $iDstHeight, $iUnit = 2, $hImgAttrib = 0)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iDstX, "int", _
    $iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", $iSrcWidth, "int", _
    $iSrcHeight, "int", $iUnit, "ptr", $hImgAttrib, "int", 0, "int", 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectEx

    [/autoit]

    mfgE

  • Frage zu WM_SETFOCUS und WM_KILLFOCUS

    • eukalyptus
    • 28. März 2010 um 12:16

    Das ist mir auch ein Rätsel!

    Du könntest jedoch WM_ACTIVATE verwenden:

    Spoiler anzeigen
    [autoit]

    Opt("GUIOnEventMode", 1)

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

    $hGUI = GUICreate("Test", 500, 500, -1, -1)
    GUISetOnEvent(-3, "_Close")
    GUIRegisterMsg(0x0006, "_WM_ACTIVATE")
    GUICtrlCreateButton("Test", 100, 100, 100, 20)
    GUISetState()

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

    While 1
    Sleep(100)
    WEnd

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

    Func _Close()
    Exit
    EndFunc

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

    Func _WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    $nCode = BitAND($wParam, 0x0000FFFF)
    Switch $nCode
    Case 0
    ToolTip("Die GUI hat den Focus verloren")
    Case Else
    ToolTip("Die GUI hat den Focus")
    EndSwitch
    Return 0
    EndFunc

    [/autoit]
  • GDI+ Rotating Cubes

    • eukalyptus
    • 28. März 2010 um 10:18
    Zitat von progandy

    Eine Lösung hätte ich eventuell: http://danbystrom.se/2009/01/12/thu…lection-in-gdi/ (Punkt 3)

    Der macht leider auch nichts anderes, als jede Spalte des Bildes mit einer neuen Höhe zu zeichnen:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile('Test.jpg')
    $iH = _GDIPlus_ImageGetHeight($hImage)
    $iW = _GDIPlus_ImageGetWidth($hImage)

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

    $hGui = GUICreate("Test", $iW, $iH)
    GUISetState()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)

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

    $Skew = $iH * 0.1
    For $i = 0 To $iW - 1
    $nH = $iH - $Skew * ($iW - $i) / $iW
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, $i, 0, 1, $iH, $i, 0, 1, $nH)
    Next

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

    While GUIGetMsg() <> -3
    Sleep(10)
    WEnd

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

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

    [/autoit]

    Das ist definitiv zu langsam!

  • Frage zu WM_SETFOCUS und WM_KILLFOCUS

    • eukalyptus
    • 28. März 2010 um 09:52

    Die beiden Funktionen müssen 0 zurückgeben:

    [autoit]

    Func _WM_SetFocus($hwnd, $message, $wParam, $lParam)
    ToolTip("Die GUI hat den Focus")
    Return 0
    EndFunc

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

    Func _WM_KillFocus($hwnd, $message, $wParam, $lParam)
    ToolTip("Die GUI hat den Focus verloren")
    Return 0
    EndFunc

    [/autoit]

    mfgE

  • GetPixelColor GDI?

    • eukalyptus
    • 26. März 2010 um 20:26
    [autoit]

    Func _GDIPlus_GetPixel($hBitmap,$X,$Y)
    ; Prog@ndy
    Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmap, "int", $X, "int", $Y, "dword*", 0)
    If @error Then Return SetError(1,0,0) ; Error, weil DllCall fehlgeschlagen ist
    Return SetError($result[0],1,$result[4]) ; Error, den die Dll-Funktion zurückliefert - Aus dem Errorcode kan mann ablesen, was genau jetzt falsch war...
    EndFunc

    [/autoit]
  • Star Wars Intro NEU

    • eukalyptus
    • 26. März 2010 um 17:54

    Hab die Font-Variablen jetzt auch für ältere AutoIt Versionen angepasst!

  • Star Wars Intro NEU

    • eukalyptus
    • 26. März 2010 um 17:28

    Danke für euer Feedback!

    Hab eine neue Version hochgeladen!
    Das Pixelige ist nun weg :thumbup:

    E

  • UDF - TrueType Fonts im Script mitgeben und verwenden

    • eukalyptus
    • 25. März 2010 um 17:06

    Mit dieser UDF kann man TrueType-Schriftarten direkt im Script mitgeben und verwenden.
    d.h.: man kann Schriftarten verwenden, welche auf dem Zielrechner nicht installiert sind und auch nicht installiert werden müssen!

    Wie bereits bei meinem Star Wars Intro verwendet hab ich die benötigten Funktionen nun zusammengefasst und ein Beispielscript dazu erstellt.

    Mit der Generate.au3 kann jeder selber eine TTF-Datei umwandeln.
    Hier kommt eine Abfrage, ob man eine höhere AutoIt Version als 3.3.4.0 verwendet.
    Die bei <JA> generierte Variable wird allerdings von Tidy AutoIt Source noch nicht unterstützt!
    Deshalb empfehle ich hier <Nein> auszuwählen

    Danke an Prog@ndy bzw. Yashied

    viel Spaß
    E

    Edit: Memfont memoryfont mem memory font schrift schriftart schriftarten script

  • Star Wars Intro NEU

    • eukalyptus
    • 24. März 2010 um 19:58
    Zitat von name22

    Das ist ja cool :thumbup:. Nur die Verzerrungen sind ein wenig lästig. :S
    Geht das nicht mit

    [autoit]

    _GDIPlus_DrawImagePoints

    [/autoit]

    ?

    Leider nein!
    Das hatte ich ursprünglich auch im Sinn.

    Bei den Verzerrungen hab ich einen Mittelwert gewählt, damit es nicht zu langsam wird.

    Bei Zeile 322 und 333 könnte man statt 200 einen höheren Wert nehmen:

    [autoit]

    For $i=10 To 1000
    $nN=(Log($i)/Log(10)*20/60)
    $nO=(Log($i-1)/Log(10)*20/60)
    $nY=$iHeight*0.4+($iHeight*0.6*$i/1000)
    $nW=($nY-$iHeight*0.3)*$iWidth/($iHeight*0.6)
    Switch $iHeight*$nN+$iTextY
    Case 0 To $iTextH
    _GDIPlus_GraphicsDrawImageRectRect($hContext,$hBitmapText,0,$iHeight*$nN+$iTextY,800,Ceiling($iHeight*$nN-$iHeight*$nO),$iWidth/2-$nW/2,$nY,$nW,Ceiling($iHeight*0.006))
    EndSwitch
    Next

    [/autoit]

    dann sind die Verzerrungen wesentlich besser, allerdings das Script auch dementsprechend langsamer!

  • Star Wars Intro NEU

    • eukalyptus
    • 24. März 2010 um 19:46

    Wieder mal ein Just4Fun-Script:

    Ich habe versucht das Intro von Star Wars zu scripten.


    Die benötigten Schriftarten sind binär im Script dabei.
    Danka an Prog@ndy für die Vorarbeit bei den PrivateFontCollection - Funktionen!

    E

    EDIT Neue Version

    Edit 2Nochmals einige Änderungen

    Dateien

    StarWars_v2.zip 1,07 MB – 955 Downloads
  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 23:09

    Bösewicht gefunden!

    Zeile88 muß natürlich so aussehen:

    [autoit]

    Local $Struct = DllStructCreate("ptr;ptr;dword;dword;hwnd;ptr")

    [/autoit]

    dann funktioniert mein Script auch auf 64Bit-Systemen

    mfgE

  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 22:40

    Ja natürlich, deine Version funktioniert wunderbar!

    Allerdings wollte ich (für mich) eine Lösung finden für eine bereits registrierte WM_PAINT Funktion
    Da geht wohl meine Variante nicht auf 64 Bit

  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 22:35

    Hab nochmals was verändert!

  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 22:28

    Zum Flacken: vielleicht hilft

    [autoit]

    If @OSVersion = "WIN_XP" Then WinSetTrans($hGui,"",0xFF)

    [/autoit]

    des weiteren sollte es so aussehen:

    [autoit]

    If $hWnd > -1 Then Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $uMsg, $wParam, $lParam)

    [/autoit]


    sonst wird das schon beim Variablensetzen aufgerufen!


    Edit verdammt! jetzt stürzt es bei mir auch ab
    war wohl nicht so gut ^^

  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 22:17

    Die Idee mit den Static Variablen finde ich sehr gut! :thumbup:

    Hab das gleich mal ausprobiert:

    Spoiler anzeigen
    [autoit]

    #include <Constants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    #cs
    Beispiel - Anfang
    #ce
    Opt('GUIOnEventMode', 1)
    Global $hGui = GUICreate('Beispiel', 600, 400)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
    GUICtrlCreateButton('Zeige Bild...', 20, 20, 160, 35)
    GUICtrlSetOnEvent(-1, '_Show')
    GUISetState()

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

    _GDIPlus_Startup()
    Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)

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

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")

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

    While Sleep(50)
    WEnd

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

    Func _End()
    Exit
    EndFunc ;==>_End

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

    Func _Show()
    Local $sPath
    $sPath = FileOpenDialog('Bilddatei auswählen', @WorkingDir, 'Images (*.jpg;*.bmp;*.png)', 3)
    If Not @error Then _ShowImage($sPath)
    EndFunc ;==>_Show
    #cs
    Beispiel - Ende
    #ce

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

    ;===============================================================================
    ; Function Name: _ShowImage($sImgFile)
    ; Description:: Zeigt ein Bild in einem separaten Fenster an.
    ; Parameter(s): $sImgFile = Pfad zu dem Bild
    ; Requirement(s): #include <GDIPlus.au3>
    ; #include <GUIConstantsEx.au3>
    ; #include <WindowsConstants.au3>
    ; Return Value(s): wenn die Datei nicht existiert wird @error auf "1" gesetzt
    ; Author(s): Oscar (http://www.autoit.de)
    ;===============================================================================
    Func _ShowImage($sImgFile)
    If Not FileExists($sImgFile) Then Return SetError(1, 0, 0)
    Local $hGui, $hBitmap, $hGraphic, $aWinPos, $iFrameWidth, $iFrameHeight, $iImgWidth, $iImgHeight, $iFactor
    Local $iOldOpt = Opt('WinTitleMatchMode', 4)
    Local $aTaskbarPos = WinGetPos('classname=Shell_TrayWnd')
    Opt('WinTitleMatchMode', $iOldOpt)
    $iOldOpt = Opt('GUIOnEventMode', 0)
    Local $iGuiWidth = 300, $iGuiHeight = 300
    $hGui = GUICreate('Calc Frame', $iGuiWidth, $iGuiHeight, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION))
    Local $bGdiStarted = False
    Switch $ghGDIPDll
    Case 0
    _GDIPlus_Startup()
    Case Else
    $bGdiStarted = True
    EndSwitch
    $hBitmap = _GDIPlus_BitmapCreateFromFile($sImgFile)
    $aWinPos = WinGetPos($hGui)
    GUIDelete($hGui)
    $iFrameWidth = $aWinPos[2] - $iGuiWidth
    $iFrameHeight = $aWinPos[3] - $iGuiHeight + 10
    $iImgWidth = _GDIPlus_ImageGetWidth($hBitmap)
    $iImgHeight = _GDIPlus_ImageGetHeight($hBitmap)
    $iFactor = $iImgWidth / $iImgHeight
    While $iImgHeight > ($aTaskbarPos[1] - $iFrameHeight)
    $iImgHeight -= 1
    $iImgWidth -= $iFactor
    WEnd
    While $iImgWidth > (@DesktopWidth - $iFrameWidth)
    $iImgHeight -= 1
    $iImgWidth -= $iFactor
    WEnd
    $iImgWidth = Int($iImgWidth)
    ConsoleWrite($iImgWidth & ' x ' & $iImgHeight & ' ' & $iFrameWidth & ' x ' & $iFrameHeight & @CR)
    $hGui = GUICreate('Show Image', $iImgWidth, $iImgHeight, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION))
    If @OSVersion = "WIN_XP" Then WinSetTrans($hGui,"",0xFF)
    GUISetState()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)

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

    Local $Struct = DllStructCreate("ptr;ptr;dword;dword;hwnd;ptr")
    DllStructSetData($Struct, 1, $hGraphic)
    DllStructSetData($Struct, 2, $hBitmap)
    DllStructSetData($Struct, 3, $iImgWidth)
    DllStructSetData($Struct, 4, $iImgHeight)
    DllStructSetData($Struct, 5, $hGui)
    Local $wProcNew = DllCallbackRegister("__ShowImage_Proc", "ptr", "hwnd;uint;long;ptr")
    Local $wProcOld = _WinAPI_SetWindowLong(WinGetHandle($hGui), $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
    DllStructSetData($Struct, 6, $wProcOld)
    __ShowImage_Proc(-1, 0, $Struct, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iImgWidth, $iImgHeight)
    While True
    $aMsg = GUIGetMsg(1)
    ;If $aMsg[0] = $GUI_EVENT_PRIMARYDOWN Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iImgWidth, $iImgHeight)
    If $aMsg[1] = $hGui And $aMsg[0] = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_SetWindowLong($hGui, $GWL_WNDPROC, $wProcOld)
    DllCallbackFree($wProcNew)
    If Not $bGdiStarted Then _GDIPlus_Shutdown()
    GUIDelete($hGui)
    Opt('GUIOnEventMode', $iOldOpt)
    EndFunc ;==>_ShowImage

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

    Func __ShowImage_Proc($hWnd, $uMsg, $wParam, $lParam)
    Local Static $hGraphic, $hBitmap, $iImgWidth, $iImgHeight, $hGui, $wProcOld
    Switch $hWnd
    Case -1 ; Variablen mit Daten befüllen
    $hGraphic = DllStructGetData($wParam, 1)
    $hBitmap = DllStructGetData($wParam, 2)
    $iImgWidth = DllStructGetData($wParam, 3)
    $iImgHeight = DllStructGetData($wParam, 4)
    $hGui = DllStructGetData($wParam, 5)
    $wProcOld = DllStructGetData($wParam, 6)
    Return
    Case $hGui
    If $uMsg = $WM_PAINT Or $uMsg = $WM_ERASEBKGND Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iImgWidth, $iImgHeight)
    EndSwitch
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $uMsg, $wParam, $lParam)
    EndFunc ;==>__ShowImage_Proc

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

    Func WM_Paint($hWnd, $uMsg, $wParam, $lParam)
    If $hWnd = $hGui Then _GDIPlus_GraphicsDrawLine($hGraphic, Random(0, 600, 1), Random(100, 400, 1), Random(0, 600, 1), Random(100, 400, 1))
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_Paint

    [/autoit]

    so kommt man auch nicht mit schon registrierten WM_PAINT Funtionen in Konflikt

    mfgE

  • _ShowImage

    • eukalyptus
    • 20. März 2010 um 20:35

    Hi

    du könntest in der Schleife auf WM_Paint abfragen!

    theoretisch sollte das so in etwa gehen, jedoch bekomm ich keine WM_Paint Messages rein!?

    [autoit]

    $PM_NOREMOVE = 0x00
    $PM_NOYIELD = 0x02
    $PM_QS_PAINT = 0x20
    $hUser32Dll = DllOpen("user32.dll")
    $msgStruct = DllStructCreate("hwnd Handle;uint message;wparam wParam;lparam lParam;dword Time;ptr Point")
    ...While...
    DllCall($hUser32Dll, "int", "PeekMessage", "ptr", DllStructGetPtr($msgStruct), "hwnd", 0, "int", 0, "int", 0, "int", $PM_QS_PAINT)
    If DllStructGetData($msgStruct, 2) = $WM_PAINT Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iImgWidth, $iImgHeight)

    [/autoit]

    Wenn man $PM_QS_PAINT weglässt, dann bekommt man auch nur die Mausmessages!
    Da muß jetzt wohl ein Profi ran ;)

    mfgE

  • FFT Bass.dll kleiner Lehrgang

    • eukalyptus
    • 16. März 2010 um 09:42

    Hi

    Den meisten ist nicht ganz klar, wie die einzelnen Frequenzbänder im Zusammenhang mit der Tonhöhe stehen.
    Diese Bänder decken alle einen gleich großen Frequenzbereich ab, allerdings entspricht eine Oktave einer Frequenzverdoppelung weshalb die "Länge" einer Oktave immer größer wird.

    Da wir aber linear denken, ist es besser die Oktaven immer gleich groß darzustellen.
    Dazu muß man jedoch die Frequenzbänder logarithmisch anordnen.

    Ich habe versucht das mit diesem Script etwas zu verdeutlichen:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Bass.au3>
    #include <BassConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $iWidth = @DesktopWidth, $iHeight = @DesktopHeight
    Global $aNoten[8 * 12][2]

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

    Global Const $pi = ATan(1) * 4

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

    _BASS_STARTUP(@ScriptDir & '\BASS.dll')
    _BASS_Init(0, -1, 44100, 0, '')
    If @error Then
    MsgBox(0, 'Error', 'Sound konnte nicht Initialisiert werden!')
    Exit
    EndIf

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

    Global $hStream = _BASS_StreamCreate(44100, 1, 0, $STREAMPROC_PUSH, 0)
    _BASS_ChannelPlay($hStream, 0)
    Global $tData = DllStructCreate("short[44100]")

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

    Global $hGui = GUICreate("FFT", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetBkColor(0x000000)
    If @OSVersion = "WIN_XP" Then WinSetTrans($hGui, "", 0xFF)
    _GDIPlus_Startup()
    Global $hBrush = _GDIPlus_BrushCreateSolid(0xFF555555)
    Global $hBrushColor = _GDIPlus_BrushCreateSolid(0xFFFFBB00)
    Global $hPen = _GDIPlus_PenCreate(0xFF555555)
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    Global $hBitmapBk = _CreateBkBmp()
    GUISetState()

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

    Global $fftstruct = DllStructCreate('float[256]')

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

    For $i = 0 To 88
    _PlayFreq($hStream, $aNoten[$i][1], 150)
    _Draw($i)
    Sleep(160)
    Next

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

    While 1
    Sleep(100)
    WEnd

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

    Func _PlayFreq($hStream, $nFreq = 440, $iMS = 1000)
    Local $iSec = Floor($iMS / 1000)
    $iMS = Mod($iMS, 1000) / 1000
    For $i = 1 To 44100
    DllStructSetData($tData, 1, 32767 * Sin($i * $pi * 2 / (44100 / $nFreq)), $i)
    Next
    For $i = 0 To $iSec
    Switch $i
    Case $iSec
    _BASS_StreamPutData($hStream, DllStructGetPtr($tData), Round(44100 * 2 * $iMS))
    Case Else
    _BASS_StreamPutData($hStream, DllStructGetPtr($tData), (44100 * 2))
    EndSwitch
    Next
    EndFunc ;==>_PlayFreq

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

    Func _Draw($iIndex = -1)
    Local $iDist = ($iWidth - 20) / 128, $iX, $iW
    _GDIPlus_GraphicsDrawImage($hContext, $hBitmapBk, 0, 0)
    _BASS_ChannelGetData($hStream, DllStructGetPtr($fftstruct), $BASS_DATA_FFT256)
    For $i = 1 To 128
    $nLevel = DllStructGetData($fftstruct, 1, $i) * 100
    If $nLevel > 20 Then
    _GDIPlus_GraphicsFillRect($hContext, $i * $iDist, 150 - $nLevel, $iDist, $nLevel, $hBrush)
    $iX = ((Log($i) / Log(10) * 20) * ($iWidth - 20)) / (Log(128) / Log(10) * 20)
    $iW = (((Log($i + 1) / Log(10) * 20) * ($iWidth - 20)) / (Log(128) / Log(10) * 20)) - $iX
    _GDIPlus_GraphicsFillRect($hContext, $iX + 10, 450 - $nLevel, $iW, $nLevel, $hBrush)
    EndIf
    Next
    Local $hFormat = _GDIPlus_StringFormatCreate(0x0004)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 8, 1)
    Local $tLayout, $aInfo
    If $iIndex >= 0 Then
    $iX = ($aNoten[$iIndex][1] * ($iWidth - 20)) / 22050
    $iY = Mod($iIndex, 12)
    $tLayout = _GDIPlus_RectFCreate($iX + 10, $iY * 10 + 150, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aNoten[$iIndex][0], $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, $aNoten[$iIndex][0], $hFont, $aInfo[0], $hFormat, $hBrushColor)

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

    $iX = ($iIndex * ($iWidth - 20)) / (89)
    $iY = Mod($iIndex, 12)
    $tLayout = _GDIPlus_RectFCreate($iX + 10, $iY * 10 + 450, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aNoten[$iIndex][0], $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, $aNoten[$iIndex][0], $hFont, $aInfo[0], $hFormat, $hBrushColor)

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

    EndIf
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    EndFunc ;==>_Draw

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

    Func _CreateBkBmp()
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hContext, 0xFF000000)
    Local $hFormat = _GDIPlus_StringFormatCreate(0x0004)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 8, 1)
    Local $tLayout, $aInfo

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

    Local $nFreq = 61.7354126570155*2
    Local $aNotenName[12] = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"]
    Local $iCnt = 0
    For $i = 0 To 7
    For $j In $aNotenName
    $nFreq = $nFreq * 2 ^ (1 / 12)
    $aNoten[$iCnt][0] = $j
    $aNoten[$iCnt][1] = Round($nFreq, 2)
    $iCnt += 1
    Next
    Next

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

    Local $iDist = ($iWidth - 20) / 128, $iX, $iW
    For $i = 1 To 128
    If Mod($i, 12) = 1 Then
    $tLayout = _GDIPlus_RectFCreate($i * $iDist, 30, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, Round($i * (44100 / 256), 1) & "Hz", $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, Round($i * (44100 / 256), 1) & "Hz", $hFont, $aInfo[0], $hFormat, $hBrush)
    EndIf
    _GDIPlus_GraphicsDrawRect($hContext, $i * $iDist, 50, $iDist, 100, $hPen)
    $iX = ((Log($i) / Log(10) * 20) * ($iWidth - 20)) / (Log(128) / Log(10) * 20)
    $iW = (((Log($i + 1) / Log(10) * 20) * ($iWidth - 20)) / (Log(128) / Log(10) * 20)) - $iX
    _GDIPlus_GraphicsDrawRect($hContext, $iX + 10, 350, $iW, 100, $hPen)
    Next
    For $i = 0 To 88
    $iX = ($aNoten[$i][1] * ($iWidth - 20)) / 22050
    $iY = Mod($i, 12)
    $tLayout = _GDIPlus_RectFCreate($iX + 10, $iY * 10 + 150, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aNoten[$i][0], $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, $aNoten[$i][0], $hFont, $aInfo[0], $hFormat, $hBrush)
    $iX = ($i * ($iWidth - 20)) / (89)
    $iY = Mod($i, 12)
    $tLayout = _GDIPlus_RectFCreate($iX + 10, $iY * 10 + 450, 0, 0)
    Switch $iY
    Case 0
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aNoten[$i][0] & " = " & Round($aNoten[$i][1], 1) & "Hz", $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, $aNoten[$i][0] & " = " & Round($aNoten[$i][1], 1) & "Hz", $hFont, $aInfo[0], $hFormat, $hBrush)
    Case Else
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $aNoten[$i][0], $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hContext, $aNoten[$i][0], $hFont, $aInfo[0], $hFormat, $hBrush)
    EndSwitch
    Next
    _GDIPlus_GraphicsDispose($hContext)
    Return $hBitmap
    EndFunc ;==>_CreateBkBmp

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

    Func _Exit()
    _BASS_Stop()
    _BASS_Free()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Achtung! lieber vorher die Lautsprecher etwas leiser machen :D

    Dateien

    fft-test.zip 137,23 kB – 513 Downloads
  • SinusTon - Synth mit Bass.dll

    • eukalyptus
    • 15. März 2010 um 21:00

    Hier ein kleiner Synth, der Sinustöne spielen kann

    nur rudimentär umgesetzt.
    und die Callback-Funktion stürzt auch hin und wieder ab

    weiters läuft das Script nicht mit einer anderen Bass.au3, weil ich bei der Funktion _BASS_StreamCreate etwas verändern mußte...

    just 4 fun

    mfgE

    Dateien

    Synth.zip 136,61 kB – 424 Downloads
  • Visualizer - gesammtes Spektrum

    • eukalyptus
    • 14. März 2010 um 09:13

    XP-Fan (Visualizer) hat mich auf den Geschmack gebracht und so hab ich auch mal einen Visualizer geschrieben.
    Skala und Pegel sind logarithmisch.

    Benötigt viel Rechenleistung; Sollte es nicht flüssig laufen, dann die Fenstergröße ganz am Anfang verkleinern

    Edit: Version 2 mit einer kleinen Waveanzeige

    Dateien

    Visualizer.zip 155,46 kB – 454 Downloads Visualizer_2.zip 155,98 kB – 550 Downloads
  • Visualizer

    • eukalyptus
    • 13. März 2010 um 10:49

    _GDIPlus_BrushCreateLinear(0, 200, 0, 400, 0xFFFF0000, 0xFF00FF00)

    wobei die erste Y-Koordinate = 400 - MaxPegel sein muß

    mfgE

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™