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

  • Nochmals FFMPEG

    • eukalyptus
    • 27. November 2010 um 18:40

    Der Parameter für die Audiobitrate ist -ab
    Die Samplerate würde ich nicht angeben (wäre außerdem -ar), denn resamplen bedeutet auch einen (kleinen) Qualitätsverlust

    Man könnte noch den Parameter -aq (=audio quality) anwenden
    Da weiß ich aber nicht auswendig, welche Werte die bessere Qualität bedeuten - steht sicher wo im www geschrieben ;)
    bessere Qualität heißt, daß der Encoder bessere Algo´s verwendet - Berechnung dauert daher länger...

    E

  • Nochmals FFMPEG

    • eukalyptus
    • 27. November 2010 um 18:10
    Zitat von Pinguin94

    ... eukalyptus
    Kannst du mir helfen?^^ (Ich sah nur: Tontechniker) :P

    Was gibt´s?

  • Per GDI+ Text auf Bild schreiben

    • eukalyptus
    • 27. November 2010 um 17:40

    Falls du die von name22 gepostete Variante mit dem Path anwenden möchtest, dann könntest du auch folgendes probieren:

    _Gdiplus_PathAddString ohne irgendwelche X-Y Einstellungen vorzunehmen
    mit _Gdiplus_PathGetWorldBounds bekommst du X,Y,W,H vom Path

    Mit einer Matrix (_gdiplus_matrixcreate, _gdiplus_matrixtranslate und _gdiplus_pathtransform)
    kannst du dann den Schriftzug an die gewünschte Position verschieben und dann zeichnen

    E


    Edit: und da ich grad Lust hatte, hab ich auch ein Beispiel erstellt:
    Die Farben des Bildes, die später unter dem Schriftzug liegen, werden ausgelesen und davon der durchschnittliche Lumawert ausgerechnet
    Wenn dieser größer als 100, dann wird eine schwarze Scrift erstellt, sonst eine weiße.

    Dieser Schritt benötigt natürlich Zeit und kann auch deaktiviert werden, wenns Schneller gehen soll

    Spoiler anzeigen
    [autoit]

    #include <GDIP.au3>
    #include <Color.au3>

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

    _GDIPlus_Startup()
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)

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

    $hBrush = _GDIPlus_BrushCreateSolid(0x6600FF00)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 2)

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

    Global $FileSearch = FileFindFirstFile(@ScriptDir & "\source\*.jpg")
    If $FileSearch = -1 Then Exit

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

    Local $file
    While 1
    $file = FileFindNextFile($FileSearch)
    If @error Then ExitLoop
    _Losung_Bild(@ScriptDir & "\source\" & $file)
    WEnd

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

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_Shutdown()

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

    Func _Losung_Bild($file, $sText = "abc")
    Local $hImage = _GDIPlus_ImageLoadFromFile($file)
    Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)

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

    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)

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

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, 50, $hFormat)

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

    Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)

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

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $iWidth - $aBounds[0] - $aBounds[2] - 10, $iHeight - $aBounds[1] - $aBounds[3] - 40)
    _GDIPlus_PathTransform($hPath, $hMatrix)

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

    _GDIPlus_MatrixDispose($hMatrix)

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

    Switch _BildHelligkeit($hImage, $hPath)
    Case 0
    _GDIPlus_BrushSetSolidColor($hBrush, 0x66FFFFFF)
    _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF)
    Case Else
    _GDIPlus_BrushSetSolidColor($hBrush, 0x66000000)
    _GDIPlus_PenSetColor($hPen, 0xFF000000)
    EndSwitch

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

    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)
    _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $hPen)

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

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)

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

    _GDIPlus_ImageSaveToFile($hImage, StringTrimRight($file, 4) & "_Text.jpg")

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

    _GDIPlus_ImageDispose($hImage)
    EndFunc ;==>_Losung_Bild

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

    Func _BildHelligkeit($hBitmap, $hPath)
    Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)

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

    Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, $aBounds[0], $aBounds[1], $aBounds[2], $aBounds[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    Local $Stride = DllStructGetData($BitmapData, "Stride")
    Local $Width = DllStructGetData($BitmapData, "Width")
    Local $Height = DllStructGetData($BitmapData, "Height")
    Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
    Local $PixelData, $Color, $Luma = 0, $iCnt = 0

    For $row = 0 To $Height - 1
    $PixelData = DllStructCreate("dword[" & $Width & ']', $Scan0 + ($row * $Stride))
    For $col = 0 To $Width - 1
    If _GDIPlus_PathIsOutlineVisiblePoint($hPath, $aBounds[0] + $col, $aBounds[1] + $row) Then
    $iCnt += 1
    $Color = DllStructGetData($PixelData, 1, $col + 1)
    $Luma += _ColorGetRed($Color) * 0.3 + _ColorGetGreen($Color) * 0.59 + _ColorGetBlue($Color) * 0.11
    EndIf
    Next
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
    $Luma /= $iCnt
    If $Luma > 100 Then Return 1
    Return 0
    EndFunc ;==>_BildHelligkeit

    [/autoit]
  • Nochmals FFMPEG

    • eukalyptus
    • 27. November 2010 um 17:29

    Ruf ffmpeg mal so auf:

    ffmpeg.exe -h > ffmpeg.txt
    und:
    ffmpeg.exe -formats > formats.txt

    dann hast du 2 Dateien, die dir vielleicht etwas weiterhelfen können...


    Edit:
    habs schnell mal probiert: ohne Parameter hat die mp4-Datei eine Audiobitrate von 64k
    wenn du die Bitrate raufsetzt, dann ist auch das Ergebnis besser:
    -ab 128k

  • Graphics Objekt von Control

    • eukalyptus
    • 25. November 2010 um 23:22
    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    Opt('MustDeclareVars', 1)

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

    _Main()

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

    Func _Main()
    Local $hGUI, $hGraphic, $hPen, $hEdit, $hDC

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

    $hGUI = GUICreate("GDI+", 400, 200)
    $hEdit = GUICtrlCreateEdit("", 30, 30, 340, 70, 0x08000000)
    GUISetState()

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

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hEdit))
    $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 10, 50, 50, $hPen)

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

    Do
    Until GUIGetMsg() = -3

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

    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_ReleaseDC($hGUI, $hDC)
    _GDIPlus_Shutdown()
    EndFunc ;==>_Main

    [/autoit]
  • ffmpeg progress bar ?

    • eukalyptus
    • 24. November 2010 um 08:53

    evtl. haben nicht alle Verionen von FFMpeg den gleichen Output - dann musst du die Funktionen etwas anpassen...

    Spoiler anzeigen
    [autoit]

    #include <Date.au3>

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

    $sStdErr = ""
    $iTicksDuration = 0
    $iTicksTime = 0

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

    ProgressOn("FFMpeg", "FFMpeg")

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

    $hPid = Run(@ScriptDir & '\ffmpeg.exe -y -i test.wav -ab 128k -ar 44100 test.mp3', @ScriptDir, @SW_HIDE, 4)
    While 1
    $sStdErr &= StderrRead($hPid)
    If @error Then ExitLoop
    If StringLen($sStdErr) > 0 Then
    If Not $iTicksDuration Then $iTicksDuration = _GetDuration($sStdErr)
    $iTicksTime = _GetTime($sStdErr)
    If Not @error Then $sStdErr = ""
    ProgressSet($iTicksTime * 100 / $iTicksDuration)
    EndIf
    WEnd
    ProgressOff()

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

    Func _GetDuration($sStdErr)
    If Not StringInStr($sStdErr, "Duration:") Then Return SetError(1, 0, 0)
    Local $aRegExp = StringRegExp($sStdErr, "(?i)Duration.+?([0-9:]+)", 3)
    If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, 0)
    Local $sTime = $aRegExp[UBound($aRegExp) - 1]
    Local $aTime = StringSplit($sTime, ":", 2)
    If @error Or Not IsArray($aTime) Then Return SetError(1, 0, 0)
    Return _TimeToTicks($aTime[0], $aTime[1], $aTime[2])
    EndFunc ;==>_GetDuration

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

    Func _GetTime($sStdErr)
    If Not StringInStr($sStdErr, "time=") Then Return SetError(1, 0, "")
    Local $aRegExp = StringRegExp($sStdErr, "(?i)time=\h*([0-9]+)", 3)
    If @error Or Not IsArray($aRegExp) Then Return SetError(1, 0, "")
    Local $sTime = $aRegExp[UBound($aRegExp) - 1]
    Return _TimeToTicks(0, 0, $sTime)
    EndFunc ;==>_GetTime

    [/autoit]
  • Visuelle Darstellung von wav Audiodateien

    • eukalyptus
    • 23. November 2010 um 00:05

    Hi

    Es wird in naher Zukunft eine Hilfe geben.
    Das gepostete Script ist z.B. schon ein Teil davon.

    Sie wird mit dann mit der Bass.au3 Version 10 veröffentlicht - das zieht sich jedoch noch etwas hin, da BrettF momentan zu wenig Zeit hat.
    Vielleicht wird das Paket noch in diesem Jahr fertig :whistling:

    E

  • Visuelle Darstellung von wav Audiodateien

    • eukalyptus
    • 22. November 2010 um 12:19

    Hier ist das Beispiel zu der Funktion _BASS_EXT_ChannelGetWaveformDecode:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n
    #include "Bass.au3"
    #include "BassExt.au3"
    #include <GDIPlus.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $sFile = FileOpenDialog("Open...", "", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)")
    ___Debug($sFile = "", $sFile)

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

    $hGui = GUICreate("WaveformDecode", 800, 250)
    GUISetOnEvent(-3, "_EXIT")
    GUISetState()

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

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics(800, 250, $hGraphics)
    $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)

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

    $hBmpBk = _GDIPlus_BitmapCreateFromGraphics(800, 250, $hGraphics)
    $hGfxBk = _GDIPlus_ImageGetGraphicsContext($hBmpBk)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBk, 2)

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

    $hPenL = _GDIPlus_PenCreate(0xFF00FF00, 1)
    $hPenR = _GDIPlus_PenCreate(0xFFFF0000, 1)
    $hBrushL = _GDIPlus_BrushCreateSolid(0xBB00BB00)
    $hBrushR = _GDIPlus_BrushCreateSolid(0xBBBB0000)
    $hPenPos = _GDIPlus_PenCreate(0xFF000099, 3)
    $hPenPos2 = _GDIPlus_PenCreate(0x99FFFF00, 1)

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

    _BASS_Startup(@ScriptDir & "\bass.dll")
    ___Debug(@error, "load bass.dll")

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

    _BASS_EXT_Startup(@ScriptDir & "\bassExt.dll")
    ___Debug(@error, "load bassext.dll")

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

    _BASS_Init(0, -1, 44100, 0, "")
    ___Debug(@error, "initialize bass")

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

    $hStreamDecode = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)
    ___Debug(@error, "create stream from file")

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

    $hStreamPlay = _BASS_StreamCreateFile(False, $sFile, 0, 0, 0)
    ___Debug(@error, "create stream from file")

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

    $iBytes = _BASS_ChannelGetLength($hStreamDecode, $BASS_POS_BYTE)
    $iLength = _BASS_ChannelBytes2Seconds($hStreamDecode, $iBytes)

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

    $iRes = 88; polygon segments per second

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

    $iWidth = $iLength * $iRes
    $aWave = _BASS_EXT_ChannelGetWaveformDecode($hStreamDecode, $iWidth, 200, 0, $iLength, $iRes, "_WaveformGetProc")

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

    _BASS_StreamFree($hStreamDecode)

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

    $hBmpWave = _BASS_EXT_GDIpBitmapCreateWaveform($hGraphics, $aWave, $hBrushL, $hPenL, $hBrushR, $hPenR, 0, 1)
    ToolTip("")

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

    _GDIPlus_GraphicsClear($hGfxBk, 0xFF000000)
    Switch $iWidth
    Case 0 To 30000
    _GDIPlus_GraphicsDrawImageRect($hGfxBk, $hBmpWave, 0, 200, 800, 50)
    Case Else
    For $i = 0 To $iWidth Step 30000
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBk, $hBmpWave, $i, 0, 30000, 200, Round($i * 800 / $iWidth), 200, Ceiling(30000 * 800 / $iWidth), 50)
    Next
    EndSwitch

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

    _BASS_ChannelPlay($hStreamPlay, True)
    ___Debug(@error, "start stream")

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

    GUIRegisterMsg(0x000F, "WM_PAINT")
    GUIRegisterMsg(0x0014, "WM_ERASEBKGND")

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

    $iTimer = TimerInit()
    While _BASS_ChannelIsActive($hStreamPlay)
    If TimerDiff($iTimer) > 20 Then
    $iTimer = TimerInit()
    $iPosByte = _BASS_ChannelGetPosition($hStreamPlay, $BASS_POS_BYTE)
    $iPosSec = _BASS_ChannelBytes2Seconds($hStreamPlay, $iPosByte)
    $iOffset = Round($iPosSec * $iRes)
    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBmpBk, 0, 0)
    _GDIPlus_GraphicsDrawLine($hGfxBuffer, 400, 2, 400, 198, $hPenPos)
    _GDIPlus_GraphicsDrawLine($hGfxBuffer, 800 * $iOffset / $iWidth, 202, 800 * $iOffset / $iWidth, 248, $hPenPos2)
    Select
    Case $iOffset < 400
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, 0, 0, 800, $aWave[6] * 4, 400 - $iOffset, 0, 800, $aWave[6] * 4)
    Case $iOffset >= $iWidth - 800
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, $iWidth - ($iWidth - $iOffset) - 400, 0, $iWidth - $iOffset + 400, $aWave[6] * 4, 0, 0, $iWidth - $iOffset + 400, $aWave[6] * 4)
    Case Else
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, $iOffset - 400, 0, 800, $aWave[6] * 4, 0, 0, 800, $aWave[6] * 4)
    EndSelect
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndIf
    Sleep(10)
    WEnd

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

    _Exit()

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

    Func _WaveformGetProc($handle, $percent)
    ToolTip("Get Waveform: " & $percent & "%")
    EndFunc ;==>_WaveformGetProc

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

    Func _Exit()
    _BASS_ChannelStop($hStreamPlay)
    ___Debug(@error, "stop stream")

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

    _BASS_StreamFree($hStreamPlay)
    ___Debug(@error, "free stream")

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

    _BASS_Free()
    ___Debug(@error, "free bass")

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

    GUIRegisterMsg(0x000F, "")
    GUIRegisterMsg(0x0014, "")
    _GDIPlus_PenDispose($hPenL)
    _GDIPlus_PenDispose($hPenR)
    _GDIPlus_BrushDispose($hBrushL)
    _GDIPlus_BrushDispose($hBrushR)
    _GDIPlus_PenDispose($hPenPos)
    _GDIPlus_PenDispose($hPenPos2)
    _GDIPlus_BitmapDispose($hBmpBk)
    _GDIPlus_GraphicsDispose($hGfxBk)
    _GDIPlus_BitmapDispose($hBmpWave)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return 'GUI_RUNDEFMSG'
    EndFunc ;==>WM_PAINT

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

    Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
    EndFunc ;==>WM_ERASEBKGND

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

    Func ___DeBug($iError, $sAction)
    Switch $iError
    Case -1
    ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
    Case 0
    ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
    Case Else
    ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
    Exit
    EndSwitch
    EndFunc ;==>___DeBug

    [/autoit]

    Die benötigten Dateien findest du beim Link, den UEZ gepostet hat

    E

  • GDI+ Bitmap "trapezoid" zeichnen / DrawImage_4Points

    • eukalyptus
    • 19. November 2010 um 09:26
    Zitat von Marsi

    ...
    Bei dir wird das Gesicht schön vergrößert... und bei eukalyptus eher die Oberweite.^^

    :D

    Meine Version (bzw. die Gimp Version) ist perspektivisch korrekt und kann als 3D-Texture verwendet werden.

    Ich hab auch noch folgende Variante probiert:
    Ich fülle einen GDIPlus-Path wieder mit Werten (1 Rechteck 1x1 pro Pixel)
    Verzerre diesen Path und fülle die entstandenen Trapeze mit der original Farbe

    Ist zwar ohne Antialiasing, sollte jedoch leichter umzusetzen sein

    Mit einem kleinen Bild probieren...

    Spoiler anzeigen
    [autoit]

    Func _GDIPlus_GraphicsDrawImage_4Points($hGraphics, $hImage, $X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4)
    ;by eukalyptus
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath = $aResult[2]

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

    Local $iW = _GDIPlus_ImageGetWidth($hImage)
    Local $iH = _GDIPlus_ImageGetHeight($hImage)

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

    For $Y = 0 To $iH - 1
    For $X = 0 To $iW - 1
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath, "float", $X, "float", $Y, "float", 1, "float", 1)
    Next
    Next

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

    Local $tWarp = DllStructCreate("float[8]")
    DllStructSetData($tWarp, 1, $X1, 1)
    DllStructSetData($tWarp, 1, $Y1, 2)
    DllStructSetData($tWarp, 1, $X2, 3)
    DllStructSetData($tWarp, 1, $Y2, 4)
    DllStructSetData($tWarp, 1, $X3, 5)
    DllStructSetData($tWarp, 1, $Y3, 6)
    DllStructSetData($tWarp, 1, $X4, 7)
    DllStructSetData($tWarp, 1, $Y4, 8)

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

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath, "hwnd", 0, "ptr", DllStructGetPtr($tWarp), "int", 4, "float", 0, "float", 0, "float", $iW, "float", $iH, "int", 0, "float", 0)

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

    Local $iCnt = $iW * $iH * 4
    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    Local $pPoints = DllStructGetPtr($tPoints)
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath, "ptr", $pPoints, "int", $iCnt)

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

    Local $tRectF = DllStructCreate("float X;float Y;float Width;float Height")
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)

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

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)

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

    Local $iNW = DllStructGetData($tRectF, 1) + DllStructGetData($tRectF, 3)
    Local $iNH = DllStructGetData($tRectF, 2) + DllStructGetData($tRectF, 4)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iNW, $iNH, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)

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

    Local $BitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    Local $Stride = DllStructGetData($BitmapData, "Stride")
    Local $Width = DllStructGetData($BitmapData, "Width")
    Local $Height = DllStructGetData($BitmapData, "Height")
    Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
    Local $PixelData
    Local $iOff = 0
    For $row = 0 To $Height - 1
    $PixelData = DllStructCreate("dword[" & $Width & ']', $Scan0 + ($row * $Stride))
    For $col = 0 To $Width - 1
    DllCall($ghGDIPDll, "int", "GdipSetSolidFillColor", "handle", $hBrush, "dword", DllStructGetData($PixelData, 1, $col + 1))
    DllCall($ghGDIPDll, "uint", "GdipFillPolygon2", "hwnd", $hContext, "hwnd", $hBrush, "ptr", $pPoints + $iOff, "int", 4)
    $iOff += 32
    Next
    Next
    _GDIPlus_BitmapUnlockBits($hImage, $BitmapData)

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

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    _GDIPlus_BitmapDispose($hBitmap)
    EndFunc ;==>_GDIPlus_GraphicsDrawImage_4Points

    [/autoit]

    E

  • Das einfachste überhaupt mach ich falsch?

    • eukalyptus
    • 14. November 2010 um 01:05

    So?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 457, 335, 193, 125)
    GUICtrlCreateLabel("Feigling's Multi Tool", 0, 0, 96, 17)
    $Button1 = GUICtrlCreateButton("Hallo Button", 144, 136, 105, 25, 0)
    $Input1 = GUICtrlCreateInput("", 80, 96, 257, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _FunctionButton1()
    EndSwitch
    WEnd

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

    Func _FunctionButton1()
    MsgBox(0,"", "Hallo " & GUICtrlRead($Input1))
    EndFunc

    [/autoit]
  • BassMidi.au3 ??

    • eukalyptus
    • 14. November 2010 um 00:42

    Nicht getestet, aber ich vermute, daß es so funktionieren sollte:

    [autoit]

    Func _BASS_MIDI_StreamGetEvents($handle, $track, $filter)
    Local $BASS_ret_ = DllCall($_ghBassMidiDll, "dword", "BASS_MIDI_StreamGetEvents", "dword", $handle, "dword", $track, "dword", $filter, "ptr", 0)
    If @error Then Return SetError(1, 1, 0)
    If $BASS_ret_[0] = $BASS_DWORD_ERR Then Return SetError(_BASS_ErrorGetCode(), 0, 0)

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

    Local $iCnt = $BASS_ret_[0]
    Local $tEvents = DllStructCreate("DWORD event[" & $iCnt & "]; DWORD param[" & $iCnt & "]; DWORD chan[" & $iCnt & "]; DWORD tick[" & $iCnt & "]; DWORD pos[" & $iCnt & "];")

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

    $BASS_ret_ = DllCall($_ghBassMidiDll, "dword", "BASS_MIDI_StreamGetEvents", "dword", $handle, "dword", $track, "dword", $filter, "ptr", DllStructGetPtr($tEvents))
    If @error Then Return SetError(1, 1, 0)
    If $BASS_ret_[0] = $BASS_DWORD_ERR Then Return SetError(_BASS_ErrorGetCode(), 0, 0)

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

    Local $aReturn[$iCnt + 1][5]
    $aReturn[0][0] = $iCnt
    For $i = 1 To $iCnt
    $aReturn[$i][0] = DllStructGetData($tEvents, "event", $i)
    $aReturn[$i][1] = DllStructGetData($tEvents, "param", $i)
    $aReturn[$i][2] = DllStructGetData($tEvents, "chan", $i)
    $aReturn[$i][3] = DllStructGetData($tEvents, "tick", $i)
    $aReturn[$i][4] = DllStructGetData($tEvents, "pos", $i)
    Next
    Return $aReturn
    EndFunc

    [/autoit]

    mfgE

  • BassMidi.au3 ??

    • eukalyptus
    • 13. November 2010 um 12:37

    Sollte so aussehen:

    [autoit]

    Global Const $BASS_MIDI_FONT = "long font; long preset; long bank"

    [/autoit]
  • BassMidi.au3 ??

    • eukalyptus
    • 13. November 2010 um 11:38

    Nimm am besten eine der mitgelieferten Quellcodes (z.b. BassMidi.bas im Verzeichnis VB) und übertrage Zeile für Zeile in AutoIt Code
    Dann hast du mal alle Konstanten und Funktionsheader fertig.

    Für die Funktionen selber halte dich an eine der fertigen UDF´s, z.B.: BassMix.au3
    Da kannst du auch vergleichen, wie die Funktionen aus BassMix.chm übersetzt wurden und es dann nachmachen...

    Ist zwar etwas Zeitaufwändig, aber sollte nicht allzu schwierig sein...

  • BassMidi.au3 ??

    • eukalyptus
    • 13. November 2010 um 11:13

    Nein, die gibt es noch nicht...

    Falls du Lust und Laune hast, könntest du ja damit anfangen :D

    mfgE

  • GDI+ Bitmap "trapezoid" zeichnen / DrawImage_4Points

    • eukalyptus
    • 13. November 2010 um 10:57

    Hab nun die "Löcher" entfernt und die Funktion zu Testzwecken in folgendes Script von UEZ bzw. Lakes eingebaut:

    Spoiler anzeigen
    [autoit]

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

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

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 1)

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

    Global $user32_dll = DllOpen("user32.dll")
    Global $Reset, $hPenDotted, $hPenDash, $ResetCube, $CubeX, $CubeY, $CubeZ
    Global $CubeX1, $CubeY1, $CubeX2, $CubeY2, $CubeX3, $CubeY3, $CubeX4, $CubeY4
    Global $Tog, $Tog1, $Tog2, $Tog3, $Tog4 = True, $Tog5, $Tog6, $Tog7 = True, $T, $Delay = 100
    Global $Text = "Press F1 to F6 to Toogle Cube Faces (F7 Toggles the Autoit Logo being Painted)"
    Global $text1 = "Left Mouse Button to Rotate, Right Mouse Button to Reset (Mouse wheel to Zoom)"

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

    Local $dot_distance = 150
    Local Const $Width = 600
    Local Const $Height = $Width
    Local Const $W2 = $Width / 2
    Local Const $H2 = $Height / 2
    Local Const $deg = 180 / ACos(-1)
    Local $hwnd = GUICreate("Orginal Code by UEZ ", $Width, $Height)

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

    GUISetState()

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

    If @OSBuild < 7600 Then WinSetTrans($hwnd, "", 0xFF) ;workaround for XP machines when alpha blending is activated on _GDIPlus_GraphicsClear() function to avoid slow drawing

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

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
    Local $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

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

    Local $sAutoItPath = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
    Local $hImage = _GDIPlus_ImageLoadFromFile($sAutoItPath & "\Examples\GUI\logo4.gif")

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

    Local $Str
    Local $pColor = 0xFF0000F0
    Local $hPen = _GDIPlus_PenCreate($pColor, 8)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)
    Local $hCubePen = _GDIPlus_PenCreate(0x400000F0, 8)
    _GDIPlus_PenSetEndCap($hCubePen, $GDIP_LINECAPARROWANCHOR)
    Local $hBrush = _GDIPlus_BrushCreateSolid()
    Local $hBrush1 = _GDIPlus_BrushCreateSolid(0x60FFFF00)
    Local $hBrush2 = _GDIPlus_BrushCreateSolid(0x60FF8000)
    $hPenDash = _GDIPlus_PenCreate(0xFF000000, 2)
    _GDIPlus_PenSetDashStyle($hPenDash, $GDIP_DASHSTYLEDASH)
    $hPenDotted = _GDIPlus_PenCreate(0xFF000000, 2)
    _GDIPlus_PenSetDashStyle($hPenDotted, $GDIP_DASHSTYLEDOT)
    Local Const $length = 250
    Local Const $Pi = ACos(-1)
    Local Const $amout_of_dots = 6
    Local Const $amout_of_cube_dots = 9

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

    #cs
    X Y Z
    ---------------------------------------
    1 [-$length, 0, 0 ], _
    2 [ $length, 0, 0 ], _
    3 [ 0, -$length, 0 ], _
    4 [ 0, $length, 0 ], _
    5 [ 0, 0, -$length ], _
    6 [ 0, 0, $length ]]
    #ce

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

    ; Axis Coords
    Local $draw_coordinates[$amout_of_dots][4] = [ _; X y Z
    [-$length, 0, 0], _
    [$length, 0, 0], _
    [0, -$length, 0], _
    [0, $length, 0], _
    [0, 0, -$length], _
    [0, 0, $length]]
    $Reset = $draw_coordinates

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

    Local $cube_coordinates[$amout_of_cube_dots][4] = [ _; X y Z
    [-$dot_distance, -$dot_distance, -$dot_distance], _
    [$dot_distance, -$dot_distance, -$dot_distance], _
    [$dot_distance, $dot_distance, -$dot_distance], _
    [-$dot_distance, $dot_distance, -$dot_distance], _
    [-$dot_distance, -$dot_distance, $dot_distance], _
    [$dot_distance, -$dot_distance, $dot_distance], _
    [$dot_distance, $dot_distance, $dot_distance], _
    [-$dot_distance, $dot_distance, $dot_distance]]
    $ResetCube = $cube_coordinates

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

    Local $x1, $y1, $x2, $y2
    Local $b, $j, $x, $y, $z, $mx, $my, $MPos
    Local $zoom_counter = 100
    Local Const $zoom_min = 50
    Local Const $zoom_max = 125
    Local Const $mouse_sense = 4000
    Local Const $start_x = $Width / 2
    Local Const $start_y = $Height / 2
    Local Const $dx = @DesktopWidth / 2, $dy = @DesktopHeight / 2
    Local Const $Red = 0xFFF00000
    Local Const $Green = 0xFF00F000
    Local Const $Blue = 0xFF0000F0
    Local $mwx, $mwy, $mwz, $angle, $rad = 180 / $Pi

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

    MouseMove($dx, $dy, 1)

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

    GUIRegisterMsg(0x020A, "WM_MOUSEWHEEL")

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

    GUISetOnEvent(-3, "Close")

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

    Do
    _GDIPlus_GraphicsClear($hBackbuffer, 0xF0FFFFFF)

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

    For $b = 0 To $amout_of_dots - 1 ;correct axis perspective
    $draw_coordinates[$b][3] = 1 + $draw_coordinates[$b][2] / 1500
    Next
    For $c = 0 To $amout_of_cube_dots - 1 ;correct cube perspective
    $cube_coordinates[$c][3] = 1 + $cube_coordinates[$c][2] / 0x600
    Next

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

    ;draw axis lines
    Draw_Lines(0, 1, $Red) ;draw x axis - red
    Draw_Lines(2, 3, $Green) ;draw y axis - green
    Draw_Lines(4, 5, $Blue) ;draw z axis - blue
    ;--------------------------------------------------------------------

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

    Select
    Case _IsPressed("70", $user32_dll)
    Sleep($Delay)
    $Tog1 = Not $Tog1
    ; Beep(100,50)

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

    Case _IsPressed("71", $user32_dll)
    Sleep($Delay)
    $Tog2 = Not $Tog2
    ; Beep(200,50)

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

    Case _IsPressed("72", $user32_dll)
    Sleep($Delay)
    $Tog3 = Not $Tog3
    ; Beep(300,50)

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

    Case _IsPressed("73", $user32_dll)
    Sleep($Delay)
    $Tog4 = Not $Tog4
    ; Beep(400,50)

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

    Case _IsPressed("74", $user32_dll)
    Sleep($Delay)
    $Tog5 = Not $Tog5
    ; Beep(500,50)

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

    Case _IsPressed("75", $user32_dll)
    Sleep($Delay)
    $Tog6 = Not $Tog6
    ; Beep(600,50)

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

    Case _IsPressed("76", $user32_dll)
    Sleep($Delay)
    $Tog7 = Not $Tog7
    ; Beep(700,50)
    EndSelect

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

    ; 4 -- - - - 5
    ; / | / |
    ; 0 - - - - 1 |
    ; | | | |
    ; | 7 -- - -|- 6
    ; | / | /
    ; 3 - - - - 2
    If $Tog1 = True Then Draw_Cube_Lines(3, 2, 6, 7) ;F1 bottom
    If $Tog2 = True Then Draw_Cube_Lines(5, 1, 0, 4) ;F2 top
    If $Tog3 = True Then Draw_Cube_Lines(1, 2, 3, 0) ;F3 front
    If $Tog4 = True Then Draw_Cube_Lines(7, 6, 5, 4) ;F4 rear
    If $Tog5 = True Then Draw_Cube_Lines(6, 2, 1, 5) ;F5 right
    If $Tog6 = True Then Draw_Cube_Lines(0, 3, 7, 4) ;F6 left

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

    If _IsPressed("01", $user32_dll) Then ; Left mouse button to Rotate
    $MPos = MouseGetPos()
    For $j = 0 To $amout_of_dots - 1
    $mx = ($dx - $MPos[0]) / $mouse_sense
    $my = -($dy - $MPos[1]) / $mouse_sense
    Calc($my, $mx, $j) ;calculate axis coordinates
    Next
    For $j = 0 To $amout_of_cube_dots - 1
    CubeCalc($my, $mx, $j) ;calculate cube coordinates
    Next
    EndIf
    If _IsPressed("02", $user32_dll) Then ;Right mouse button to Reset CoOrds and Toggles to inital values
    $draw_coordinates = $Reset
    $cube_coordinates = $ResetCube
    $Tog1 = False
    $Tog2 = False
    $Tog3 = False
    $Tog4 = True ;Draw this Face as Default
    $Tog5 = False
    $Tog6 = False
    $Tog7 = True ;Paint Logo
    EndIf

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

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Width, $Height)
    Until Not Sleep(30)

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

    ;Draw Axis Lines
    Func Draw_Lines($p1, $p2, $pColor)
    $x1 = $start_x + $draw_coordinates[$p1][0] * $draw_coordinates[$p1][3]
    $y1 = $start_y + $draw_coordinates[$p1][1] * $draw_coordinates[$p1][3]

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

    $x2 = $start_x + $draw_coordinates[$p2][0] * $draw_coordinates[$p2][3]
    $y2 = $start_y + $draw_coordinates[$p2][1] * $draw_coordinates[$p2][3]

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

    _GDIPlus_PenSetColor($hPen, $pColor)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x1, $y1, $x2, $y2, $hPen)

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

    _GDIPlus_BrushSetSolidColor($hBrush, $pColor)
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $x1 - 10, $y1 - 10, 20, 20, $hBrush)

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

    $angle = Mod(360 - Abs(Angle($draw_coordinates[$p1][0], $draw_coordinates[$p2][1])), 360)
    Select
    Case $pColor = $Red
    $Str = "XAngle = " & StringFormat("%.2f", $angle)
    Case $pColor = $Green
    $Str = "YAngle = " & StringFormat("%.2f", $angle)
    Case $pColor = $Blue
    $Str = "ZAngle = " & StringFormat("%.2f", $angle)
    EndSelect
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $start_x - 10, $start_y - 10, 20, 20, 0) ; Origin
    _GDIPlus_GraphicsDrawString($hBackbuffer, "Origin", $start_x - 20, $start_y - 30)
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Str, $x2 - 20, $y2 - 30)
    EndFunc ;==>Draw_Lines

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

    Func Draw_Cube_Lines($Cp1, $Cp2, $Cp3, $Cp4)
    $CubeX1 = $start_x + $cube_coordinates[$Cp1][0] * $cube_coordinates[$Cp1][3]
    $CubeY1 = $start_y + $cube_coordinates[$Cp1][1] * $cube_coordinates[$Cp1][3]

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

    $CubeX2 = $start_x + $cube_coordinates[$Cp2][0] * $cube_coordinates[$Cp2][3]
    $CubeY2 = $start_y + $cube_coordinates[$Cp2][1] * $cube_coordinates[$Cp2][3]

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

    $CubeX3 = $start_x + $cube_coordinates[$Cp3][0] * $cube_coordinates[$Cp3][3]
    $CubeY3 = $start_y + $cube_coordinates[$Cp3][1] * $cube_coordinates[$Cp3][3]

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

    $CubeX4 = $start_x + $cube_coordinates[$Cp4][0] * $cube_coordinates[$Cp4][3]
    $CubeY4 = $start_y + $cube_coordinates[$Cp4][1] * $cube_coordinates[$Cp4][3]

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

    ;####### For Front Face #########
    ;------------------------------- Top -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX4, $CubeY4, $CubeX1, $CubeY1, $hCubePen) ; top 0 - 1
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $CubeX4 - 5, $CubeY4 - 5, 10, 10, 0)

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

    _GDIPlus_GraphicsDrawLine($hBackbuffer, $start_x, $start_y, $CubeX4, $CubeY4, $hPenDash)
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Cp4, $CubeX4 - 10, $CubeY4 - 20, "Arial", 12)
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Cp1, $CubeX1, $CubeY1 - 20, "Arial", 12)
    ;-------------------------------------------------------------------------------------------
    ;------------------------------- Right -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX1, $CubeY1, $CubeX2, $CubeY2, $hCubePen) ; right 2 - 1
    ;---------------------------------------------------------------------------------------------
    ;------------------------------- Bottom -------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX2, $CubeY2, $CubeX3, $CubeY3, $hCubePen) ; bottom 3 - 2
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $CubeX2 - 5, $CubeY2 - 5, 10, 10, 0)

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

    _GDIPlus_GraphicsDrawLine($hBackbuffer, $start_x, $start_y, $CubeX2, $CubeY2, $hPenDash)
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Cp2, $CubeX2 + 5, $CubeY2, "Arial", 12)
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Cp3, $CubeX3 - 10, $CubeY3, "Arial", 12)
    ;----------------------------------------------------------------------------------------------
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Text, 5, 550, "Arial", 12) ;Instructions
    _GDIPlus_GraphicsDrawString($hBackbuffer, $text1, 5, 570, "Arial", 12)

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

    ;------------------------------- Left --------------------------------------------------------
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $CubeX3, $CubeY3, $CubeX4, $CubeY4, $hCubePen) ; left
    ;----------------------------------------------------------------------------------------------
    _GDIPlus_GraphicsDrawString($hBackbuffer, $Cp3, $CubeX3 - 10, $CubeY3, "Arial", 12)
    ;--------------------------- Put the Autoit Logo image on one Face ----------------------------------------------
    If $Cp1 = 7 And $Tog7 = True Then
    _GDIPlus_GraphicsDrawImage_4Points($hBackbuffer, $hImage, $CubeX4, $CubeY4, _
    $CubeX3, $CubeY3, _
    $CubeX1, $CubeY1, _
    $CubeX2, $CubeY2, 0.05)
    EndIf
    EndFunc ;==>Draw_Cube_Lines

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

    Func _GDIPlus_GraphicsDrawImage_4Points($hGraphics, $hImage, $X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4, $fPrecision = 0.25)
    ;by eukalyptus
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath = $aResult[2]

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

    Local $iW = _GDIPlus_ImageGetWidth($hImage)
    Local $iH = _GDIPlus_ImageGetHeight($hImage)

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

    If $fPrecision <= 0 Then $fPrecision = 0.01
    If $fPrecision > 1 Then $fPrecision = 1

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

    Local $iTX = Ceiling($iW * $fPrecision)
    Local $iTY = Ceiling($iH * $fPrecision)
    Local $iCnt = ($iTX + 1) * ($iTY + 1)
    Local $X, $Y

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

    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    Local $I
    For $Y = 0 To $iTY
    For $X = 0 To $iTX
    $I = ($Y * ($iTX + 1) + $X) * 2
    DllStructSetData($tPoints, 1, $X * $iW / $iTX, $I + 1)
    DllStructSetData($tPoints, 1, $Y * $iH / $iTY, $I + 2)
    Next
    Next

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 2, False)

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

    Local $tWarp = DllStructCreate("float[8]")
    DllStructSetData($tWarp, 1, $X1, 1)
    DllStructSetData($tWarp, 1, $Y1, 2)
    DllStructSetData($tWarp, 1, $X2, 3)
    DllStructSetData($tWarp, 1, $Y2, 4)
    DllStructSetData($tWarp, 1, $X3, 5)
    DllStructSetData($tWarp, 1, $Y3, 6)
    DllStructSetData($tWarp, 1, $X4, 7)
    DllStructSetData($tWarp, 1, $Y4, 8)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath, "hwnd", 0, "ptr", DllStructGetPtr($tWarp), "int", 4, "float", 0, "float", 0, "float", $iW, "float", $iH, "int", 0, "float", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)

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

    Local $tRectF = DllStructCreate("float X;float Y;float Width;float Height")
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 5, False)

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

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)

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

    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(DllStructGetData($tRectF, 1) + DllStructGetData($tRectF, 3), DllStructGetData($tRectF, 2) + DllStructGetData($tRectF, 4), $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    Local $tDraw = DllStructCreate("float[6]")
    Local $pDraw = DllStructGetPtr($tDraw)
    Local $W = $iW / $iTX
    Local $H = $iH / $iTY
    Local $iO = ($iTX + 1) * 2
    Local $fX1, $fY1, $fX2, $fY2, $fX3, $fY3, $fSX, $fSY

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

    For $Y = 0 To $iTY - 1
    For $X = 0 To $iTX - 1
    $I = ($Y * ($iTX + 1) + $X) * 2
    $fX1 = DllStructGetData($tPoints, 1, $I + 1)
    $fY1 = DllStructGetData($tPoints, 1, $I + 2)

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

    Switch $X
    Case $iTX - 1
    $fX2 = DllStructGetData($tPoints, 1, $I + 3)
    $fY2 = DllStructGetData($tPoints, 1, $I + 4)
    $fSX = 1
    Case Else
    $fX2 = DllStructGetData($tPoints, 1, $I + 5)
    $fY2 = DllStructGetData($tPoints, 1, $I + 6)
    $fSX = 2
    EndSwitch

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

    Switch $Y
    Case $iTY - 1
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO)
    $fSY = 1
    Case Else
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO * 2)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO * 2)
    $fSY = 2
    EndSwitch

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

    DllStructSetData($tDraw, 1, $fX1, 1)
    DllStructSetData($tDraw, 1, $fY1, 2)
    DllStructSetData($tDraw, 1, $fX2, 3)
    DllStructSetData($tDraw, 1, $fY2, 4)
    DllStructSetData($tDraw, 1, $fX3, 5)
    DllStructSetData($tDraw, 1, $fY3, 6)

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

    DllCall($ghGDIPDll, "uint", "GdipDrawImagePointsRect", "hwnd", $hContext, "hwnd", $hImage, "ptr", $pDraw, "int", 3, "float", $X * $W, "float", $Y * $H, "float", $W * $fSX, "float", $H * $fSY, "int", 2, "hwnd", 0, "ptr", 0, "ptr", 0)
    Next
    Next

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

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    _GDIPlus_BitmapDispose($hBitmap)
    EndFunc ;==>_GDIPlus_GraphicsDrawImage_4Points

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

    Func Angle($x, $y)
    Local $angle
    If $x = 0 Then
    $angle = 0
    Else
    $angle = -ATan($y / - $x) * $deg
    EndIf
    If - $x < 0 Then
    $angle = -180 + $angle
    ElseIf - $x >= 0 And $y < 0 Then
    $angle = -360 + $angle
    EndIf
    Return $angle
    EndFunc ;==>Angle

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

    Func Calc($angle_x, $angle_y, $I, $angle_z = 0)
    ;calculate axis 3D rotation
    $x = $draw_coordinates[$I][0] * Cos($angle_y) + $draw_coordinates[$I][2] * Sin($angle_y)
    $y = $draw_coordinates[$I][1]
    $z = -$draw_coordinates[$I][0] * Sin($angle_y) + $draw_coordinates[$I][2] * Cos($angle_y)

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

    $draw_coordinates[$I][0] = $x
    $draw_coordinates[$I][1] = $y * Cos($angle_x) - $z * Sin($angle_x)
    $draw_coordinates[$I][2] = $y * Sin($angle_x) + $z * Cos($angle_x)
    EndFunc ;==>Calc

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

    Func CubeCalc($angle_x, $angle_y, $I)
    ;calculate Cube 3D rotation
    $CubeX = $cube_coordinates[$I][0] * Cos($angle_y) + $cube_coordinates[$I][2] * Sin($angle_y)
    $CubeY = $cube_coordinates[$I][1]
    $CubeZ = -$cube_coordinates[$I][0] * Sin($angle_y) + $cube_coordinates[$I][2] * Cos($angle_y)

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

    $cube_coordinates[$I][0] = $CubeX
    $cube_coordinates[$I][1] = $CubeY * Cos($angle_x) - $CubeZ * Sin($angle_x)
    $cube_coordinates[$I][2] = $CubeY * Sin($angle_x) + $CubeZ * Cos($angle_x)
    EndFunc ;==>CubeCalc

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

    Func Close()
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPenDash)
    _GDIPlus_PenDispose($hPenDotted)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    DllClose($user32_dll)
    Exit
    EndFunc ;==>Close

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

    Func Zoom($factor)
    Local $m
    For $m = 0 To $amout_of_dots - 1
    $draw_coordinates[$m][0] *= $factor
    $draw_coordinates[$m][1] *= $factor
    $draw_coordinates[$m][2] *= $factor
    Next
    For $m = 0 To $amout_of_cube_dots - 1
    $cube_coordinates[$m][0] *= $factor
    $cube_coordinates[$m][1] *= $factor
    $cube_coordinates[$m][2] *= $factor
    Next
    EndFunc ;==>Zoom

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

    Func WM_MOUSEWHEEL($hwnd, $iMsg, $wParam, $lParam)
    Local $wheel_Dir = BitAND($wParam, 0x800000)
    If $wheel_Dir > 0 Then
    If $zoom_counter <= $zoom_max Then
    Zoom(1.05)
    $zoom_counter += 1
    EndIf
    Else
    If $zoom_counter >= $zoom_min Then
    Zoom(0.95)
    $zoom_counter -= 1
    EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
    EndFunc ;==>WM_MOUSEWHEEL

    [/autoit]

    Wenn man das mit Assembler noch beschleunigen könnte, wäre das natürlich der Hammer :thumbup:

  • GDI+ Bitmap "trapezoid" zeichnen / DrawImage_4Points

    • eukalyptus
    • 13. November 2010 um 01:54

    Hi

    Wie manche schon wissen, kann man mit der Funtion _GDIPlus_DrawImagePoints ein Bitmap als Parallelogramm (3 Punkt) zeichnen.
    Ich suche schon seit langem nach einer Möglichkeit die Bilder als Trapeze (4 Punkt) zu zeichnen

    Nun hab ich eben solch eine Funktion geschrieben, allerdings ist sie nicht gerade die schnellste :whistling:
    Man kann aber die Geschwindigkeit auf Kosten der Prezision erhöhen; von 0 (schnell/grob) bis 1 (langsam/fein)
    Des weiteren treten bei zu starken Verzerrungen Löcher im fertigen Bild auf - das muss ich erst irgendwann mal beheben.

    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    _GDIPlus_GraphicsDrawImage_4Points:

    Spoiler anzeigen
    [autoit]

    Func _GDIPlus_GraphicsDrawImage_4Points($hGraphics, $hImage, $X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4, $fPrecision = 0.25)
    ;by eukalyptus
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath = $aResult[2]

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

    Local $iW = _GDIPlus_ImageGetWidth($hImage)
    Local $iH = _GDIPlus_ImageGetHeight($hImage)

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

    If $fPrecision <= 0 Then $fPrecision = 0.01
    If $fPrecision > 1 Then $fPrecision = 1

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

    Local $iTX = Ceiling($iW * $fPrecision)
    Local $iTY = Ceiling($iH * $fPrecision)
    Local $iCnt = ($iTX + 1) * ($iTY + 1)
    Local $X, $Y

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

    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    Local $I
    For $Y = 0 To $iTY
    For $X = 0 To $iTX
    $I = ($Y * ($iTX + 1) + $X) * 2
    DllStructSetData($tPoints, 1, $X * $iW / $iTX, $I + 1)
    DllStructSetData($tPoints, 1, $Y * $iH / $iTY, $I + 2)
    Next
    Next

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 2, False)

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

    Local $tWarp = DllStructCreate("float[8]")
    DllStructSetData($tWarp, 1, $X1, 1)
    DllStructSetData($tWarp, 1, $Y1, 2)
    DllStructSetData($tWarp, 1, $X2, 3)
    DllStructSetData($tWarp, 1, $Y2, 4)
    DllStructSetData($tWarp, 1, $X3, 5)
    DllStructSetData($tWarp, 1, $Y3, 6)
    DllStructSetData($tWarp, 1, $X4, 7)
    DllStructSetData($tWarp, 1, $Y4, 8)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath, "hwnd", 0, "ptr", DllStructGetPtr($tWarp), "int", 4, "float", 0, "float", 0, "float", $iW, "float", $iH, "int", 0, "float", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)

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

    Local $tRectF = DllStructCreate("float X;float Y;float Width;float Height")
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 5, False)

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

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)

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

    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(DllStructGetData($tRectF, 1) + DllStructGetData($tRectF, 3), DllStructGetData($tRectF, 2) + DllStructGetData($tRectF, 4), $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    Local $tDraw = DllStructCreate("float[6]")
    Local $pDraw = DllStructGetPtr($tDraw)
    Local $W = $iW / $iTX
    Local $H = $iH / $iTY
    Local $iO = ($iTX + 1) * 2
    Local $fX1, $fY1, $fX2, $fY2, $fX3, $fY3, $fSX, $fSY

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

    For $Y = 0 To $iTY - 1
    For $X = 0 To $iTX - 1
    $I = ($Y * ($iTX + 1) + $X) * 2
    $fX1 = DllStructGetData($tPoints, 1, $I + 1)
    $fY1 = DllStructGetData($tPoints, 1, $I + 2)

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

    Switch $X
    Case $iTX - 1
    $fX2 = DllStructGetData($tPoints, 1, $I + 3)
    $fY2 = DllStructGetData($tPoints, 1, $I + 4)
    $fSX = 1
    Case Else
    $fX2 = DllStructGetData($tPoints, 1, $I + 5)
    $fY2 = DllStructGetData($tPoints, 1, $I + 6)
    $fSX = 2
    EndSwitch

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

    Switch $Y
    Case $iTY - 1
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO)
    $fSY = 1
    Case Else
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO * 2)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO * 2)
    $fSY = 2
    EndSwitch

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

    DllStructSetData($tDraw, 1, $fX1, 1)
    DllStructSetData($tDraw, 1, $fY1, 2)
    DllStructSetData($tDraw, 1, $fX2, 3)
    DllStructSetData($tDraw, 1, $fY2, 4)
    DllStructSetData($tDraw, 1, $fX3, 5)
    DllStructSetData($tDraw, 1, $fY3, 6)

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

    DllCall($ghGDIPDll, "uint", "GdipDrawImagePointsRect", "hwnd", $hContext, "hwnd", $hImage, "ptr", $pDraw, "int", 3, "float", $X * $W, "float", $Y * $H, "float", $W * $fSX, "float", $H * $fSY, "int", 2, "hwnd", 0, "ptr", 0, "ptr", 0)
    Next
    Next

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

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    _GDIPlus_BitmapDispose($hBitmap)
    EndFunc ;==>_GDIPlus_GraphicsDrawImage_4Points

    [/autoit]

    Beispiel:

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GuiOnEventMode", 1)

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

    Global $aDrag[5][2] = [[0, 0],[0, 0],[800, 50],[100, 530],[700, 450]]

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

    $hGui = GUICreate("DrawImage_4Points Test", 800, 580)
    GUISetOnEvent(-3, "_Exit")
    GUICtrlCreateButton("render with higher precision", 200, 550, 200, 20)
    GUICtrlSetOnEvent(-1, "_Render")
    GUICtrlCreateLabel("precision:", 410, 550, 80, 20, 0x0002)
    $cSlider = GUICtrlCreateSlider(500, 545, 100, 25)
    GUICtrlSetData(-1, 25)
    GUICtrlSetOnEvent(-1, "_Slider")
    $cLabel = GUICtrlCreateLabel("0.25", 610, 550, 50, 20)

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

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics(800, 540, $hGraphics)
    $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

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

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUISetState()

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

    $hBrush = _GDIPlus_BrushCreateSolid(0x8800FF00)
    $hPen = _GDIPlus_PenCreate(0xFFFF0000)

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

    $sFile = FileOpenDialog("open image", "", "(*.jpg;*.bmp;*.png;*.tif;*.gif)")
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)

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

    _ReDraw(0.02)

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

    $iIndex = 0
    While 1
    $aInfo = GUIGetCursorInfo($hGui)

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

    If Not $aInfo[2] Then $iIndex = 0
    Switch $iIndex
    Case 0
    If $aInfo[2] Then
    For $I = 1 To 4
    If $aInfo[0] > $aDrag[$I][0] - 5 And $aInfo[0] < $aDrag[$I][0] + 5 And $aInfo[1] > $aDrag[$I][1] - 5 And $aInfo[1] < $aDrag[$I][1] + 5 Then
    $iIndex = $I
    ExitLoop
    EndIf
    Next
    EndIf
    Case Else
    $aDrag[$iIndex][0] = $aInfo[0]
    $aDrag[$iIndex][1] = $aInfo[1]
    _ReDraw(0.02)
    EndSwitch

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

    Sleep(20)
    WEnd

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

    Func _GDIPlus_GraphicsDrawImage_4Points($hGraphics, $hImage, $X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4, $fPrecision = 0.25)
    ;by eukalyptus
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath = $aResult[2]

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

    Local $iW = _GDIPlus_ImageGetWidth($hImage)
    Local $iH = _GDIPlus_ImageGetHeight($hImage)

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

    If $fPrecision <= 0 Then $fPrecision = 0.01
    If $fPrecision > 1 Then $fPrecision = 1

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

    Local $iTX = Ceiling($iW * $fPrecision)
    Local $iTY = Ceiling($iH * $fPrecision)
    Local $iCnt = ($iTX + 1) * ($iTY + 1)
    Local $X, $Y

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

    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    Local $I
    For $Y = 0 To $iTY
    For $X = 0 To $iTX
    $I = ($Y * ($iTX + 1) + $X) * 2
    DllStructSetData($tPoints, 1, $X * $iW / $iTX, $I + 1)
    DllStructSetData($tPoints, 1, $Y * $iH / $iTY, $I + 2)
    Next
    Next

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 2, False)

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

    Local $tWarp = DllStructCreate("float[8]")
    DllStructSetData($tWarp, 1, $X1, 1)
    DllStructSetData($tWarp, 1, $Y1, 2)
    DllStructSetData($tWarp, 1, $X2, 3)
    DllStructSetData($tWarp, 1, $Y2, 4)
    DllStructSetData($tWarp, 1, $X3, 5)
    DllStructSetData($tWarp, 1, $Y3, 6)
    DllStructSetData($tWarp, 1, $X4, 7)
    DllStructSetData($tWarp, 1, $Y4, 8)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath, "hwnd", 0, "ptr", DllStructGetPtr($tWarp), "int", 4, "float", 0, "float", 0, "float", $iW, "float", $iH, "int", 0, "float", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)

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

    Local $tRectF = DllStructCreate("float X;float Y;float Width;float Height")
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 5, False)

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

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)

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

    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(DllStructGetData($tRectF, 1) + DllStructGetData($tRectF, 3), DllStructGetData($tRectF, 2) + DllStructGetData($tRectF, 4), $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    Local $tDraw = DllStructCreate("float[6]")
    Local $pDraw = DllStructGetPtr($tDraw)
    Local $W = $iW / $iTX
    Local $H = $iH / $iTY
    Local $iO = ($iTX + 1) * 2
    Local $fX1, $fY1, $fX2, $fY2, $fX3, $fY3, $fSX, $fSY

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

    For $Y = 0 To $iTY - 1
    For $X = 0 To $iTX - 1
    $I = ($Y * ($iTX + 1) + $X) * 2
    $fX1 = DllStructGetData($tPoints, 1, $I + 1)
    $fY1 = DllStructGetData($tPoints, 1, $I + 2)

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

    Switch $X
    Case $iTX - 1
    $fX2 = DllStructGetData($tPoints, 1, $I + 3)
    $fY2 = DllStructGetData($tPoints, 1, $I + 4)
    $fSX = 1
    Case Else
    $fX2 = DllStructGetData($tPoints, 1, $I + 5)
    $fY2 = DllStructGetData($tPoints, 1, $I + 6)
    $fSX = 2
    EndSwitch

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

    Switch $Y
    Case $iTY - 1
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO)
    $fSY = 1
    Case Else
    $fX3 = DllStructGetData($tPoints, 1, $I + 1 + $iO * 2)
    $fY3 = DllStructGetData($tPoints, 1, $I + 2 + $iO * 2)
    $fSY = 2
    EndSwitch

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

    DllStructSetData($tDraw, 1, $fX1, 1)
    DllStructSetData($tDraw, 1, $fY1, 2)
    DllStructSetData($tDraw, 1, $fX2, 3)
    DllStructSetData($tDraw, 1, $fY2, 4)
    DllStructSetData($tDraw, 1, $fX3, 5)
    DllStructSetData($tDraw, 1, $fY3, 6)

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

    DllCall($ghGDIPDll, "uint", "GdipDrawImagePointsRect", "hwnd", $hContext, "hwnd", $hImage, "ptr", $pDraw, "int", 3, "float", $X * $W, "float", $Y * $H, "float", $W * $fSX, "float", $H * $fSY, "int", 2, "hwnd", 0, "ptr", 0, "ptr", 0)
    Next
    Next

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

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    _GDIPlus_BitmapDispose($hBitmap)
    EndFunc ;==>_GDIPlus_GraphicsDrawImage_4Points

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

    Func _ReDraw($fPrecision)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImage_4Points($hGfxBuffer, $hImage, $aDrag[1][0], $aDrag[1][1], $aDrag[2][0], $aDrag[2][1], $aDrag[3][0], $aDrag[3][1], $aDrag[4][0], $aDrag[4][1], $fPrecision)
    For $I = 1 To 4
    _GDIPlus_GraphicsFillRect($hGfxBuffer, $aDrag[$I][0] - 5, $aDrag[$I][1] - 5, 10, 10, $hBrush)
    _GDIPlus_GraphicsDrawRect($hGfxBuffer, $aDrag[$I][0] - 5, $aDrag[$I][1] - 5, 10, 10, $hPen)
    Next
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_ReDraw

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

    Func _Slider()
    GUICtrlSetData($cLabel, GUICtrlRead($cSlider) / 100)
    EndFunc ;==>_Slider

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

    Func _Render()
    Local $fPrecision = GUICtrlRead($cSlider) / 100
    SplashTextOn("Rendering with precision " & $fPrecision, "please wait", 250, 50)
    _ReDraw($fPrecision)
    SplashOff()
    EndFunc ;==>_Render

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

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

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

    Func _Exit()
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]


    Beim Beispiel einfach die grünen Eckpunkte mit der Maus verziehen und dann auf "Render" klicken

    E

    Dateien

    Test_2.JPG 25,58 kB – 0 Downloads Test_1.JPG 21,43 kB – 0 Downloads
  • BASS_StreamFree automatisch (Bass.dll)

    • eukalyptus
    • 13. November 2010 um 01:37

    Ja gibt es: $BASS_STREAM_AUTOFREE

    Sei mir jetzt nicht bös, aber vielleicht solltest du dir mal die Bass*.chm besorgen (https://autoit.de/www.un4seen.com).
    Da stehen solche Sachen drin ;)

    mfgE

  • AutoBert hat Geburtstag

    • eukalyptus
    • 13. November 2010 um 01:34

    Alles Gute! :party:

  • Xenobiologist wird heute 31 Jahre

    • eukalyptus
    • 13. November 2010 um 01:34

    Na, da schließ ich mich doch gerne an!

    Alles Gute!

  • Word aus 2 Byte erstellen fehlerhaft

    • eukalyptus
    • 12. November 2010 um 14:07

    Das ist kein Fehler - word ist immer positiv
    -2 short = 65534 word

    du könntest "short" statt "word" in Zeile 21 verwenden...

    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™