So:
[autoit]#include <Array.au3>
$sStr = 'Abcdef"ghi"jklmno"pqrstuvw"xyz'
$aRegEx = StringRegExp($sStr, '["][^"]*["]|\w+', 3)
_ArrayDisplay($aRegEx)
E
So:
[autoit]#include <Array.au3>
$sStr = 'Abcdef"ghi"jklmno"pqrstuvw"xyz'
$aRegEx = StringRegExp($sStr, '["][^"]*["]|\w+', 3)
_ArrayDisplay($aRegEx)
E
Danke!
bevor ich die Formeln verstehe, werden wohl noch ein paar Sonnen untergehen
Für meine Zwecke reicht es momentan
thx
E
Du musst ein Bitmap statt eines GUI verwenden, um das Bild zu erstellen:
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]Dim $File_Background = '' ;Pfad zur Hintergrunddatei
Dim $File_Transparent = '' ;Pfad für Transparente Datei für den Vordergrund
Dim $Draw_BackgroundFile = True ;Hintergrundbild oder nur Farbe zeichnen
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$hGui = GUICreate('sichtbare GUI', 500, 300)
GUISetState()
_GDIPlus_Startup()
$hDrawBitmap = _GDIPlus_BitmapCreateFromScan0(1280, 720)
$hDrawContext = _GDIPlus_ImageGetGraphicsContext($hDrawBitmap)
$hgraphics_hGui = _GDIPlus_GraphicsCreateFromHWND($hGui)
[/autoit] [autoit][/autoit] [autoit]$Image_Picture = _GDIPlus_ImageLoadFromFile($File_Transparent)
$Image_Background = _GDIPlus_ImageLoadFromFile($File_Background)
$hBrush = _GDIPlus_BrushCreateSolid(0xff00ff00)
If $Draw_BackgroundFile = True Then
_GDIPlus_GraphicsDrawImageRect($hDrawContext, $Image_Background, 0, 0, 1280, 720)
Else
_GDIPlus_GraphicsFillRect($hDrawContext,0,0,1280,720,$hBrush)
EndIf
_GDIPlus_GraphicsDrawImageRect($hDrawContext,$Image_Picture,0,0,1280,720)
_GDIPlus_GraphicsDrawString($hDrawContext, 'Test String',10,10,'Arial',100)
_GDIPlus_GraphicsDrawImageRect($hgraphics_hGui, $hDrawBitmap, 50,50,400,400/16*9) ; nun alles auf die sichtbare GUI zeichnen
_GDIPlus_ImageSaveToFile($hDrawBitmap,@ScriptDir&'\Test.jpg')
_GDIPlus_GraphicsDispose($Image_Picture)
_GDIPlus_GraphicsDispose($Image_Background)
_GDIPlus_GraphicsDispose($hDrawContext)
_GDIPlus_BitmapDispose($hDrawBitmap)
_GDIPlus_BitmapDispose($Image_Background)
_GDIPlus_BitmapDispose($Image_Picture)
_GDIPlus_GraphicsDispose($hgraphics_hGui)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_Shutdown()
Sleep(2500)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_BitmapCreateFromScan0
; Description ...: Creates a Bitmap object based on an array of bytes along with size and format information
; Syntax.........: _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight[, $iStride = 0[, $iPixelFormat = 0x0026200A[, $pScan0 = 0]]])
; Parameters ....: $iWidth - The bitmap width, in pixels
; $iHeight - The bitmap height, in pixels
; $iStride - Integer that specifies the byte offset between the beginning of one scan line and the next. This
; +is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel)
; +multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four
; $iPixelFormat - Specifies the format of the pixel data. Can be one of the following:
; |$GDIP_PXF01INDEXED - 1 bpp, indexed
; |$GDIP_PXF04INDEXED - 4 bpp, indexed
; |$GDIP_PXF08INDEXED - 8 bpp, indexed
; |$GDIP_PXF16GRAYSCALE - 16 bpp, grayscale
; |$GDIP_PXF16RGB555 - 16 bpp; 5 bits for each RGB
; |$GDIP_PXF16RGB565 - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue
; |$GDIP_PXF16ARGB1555 - 16 bpp; 1 bit for alpha and 5 bits for each RGB component
; |$GDIP_PXF24RGB - 24 bpp; 8 bits for each RGB
; |$GDIP_PXF32RGB - 32 bpp; 8 bits for each RGB. No alpha.
; |$GDIP_PXF32ARGB - 32 bpp; 8 bits for each RGB and alpha
; |$GDIP_PXF32PARGB - 32 bpp; 8 bits for each RGB and alpha, pre-mulitiplied
; $pScan0 - Pointer to an array of bytes that contains the pixel data. The caller is responsible for
; +allocating and freeing the block of memory pointed to by this parameter.
; Return values .: Success - Returns a handle to a new Bitmap object
; Failure - 0 and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
; Related .......: _GDIPlus_ImageDispose
; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromScan0
; Example .......; Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
$GDIP_STATUS = $aResult[0]
Return $aResult[6]
EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
E
Danke! Das hat schonmal sehr geholfen!
Aber ganz korrekt ist deine Berechnung auch nicht.
Wenn du in deiner Darstellung den Zeitbereich von 2.5 bis 3 betrachtest, dann siehst du dort etwa 4 Schwingungen = 8 Schwingungen / Sekunde
Deshalb musste ich "m" noch durch 2 Teilen um am Ende auf 4 Hz zu kommen.
Warum ist das so?
Hier mein Script dazu:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global Const $cPI = ATan(1) * 4
Global Const $c2PI = $cPI * 2
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $iWidth = 800
Global $iHeight = 600
Global $hGui = GUICreate("AutoIt GDI+", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
Global $hPen_R = _GDIPlus_PenCreate(0xFFFF0000)
Global $hPen_G = _GDIPlus_PenCreate(0xFF00FF00)
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
GUISetState()
Global $fFreqS = 1
Global $fFreqE = 4
Global $fTime = 3
_DrawSine($fFreqS, $fTime, $iHeight * 0.25)
_DrawSine($fFreqE, $fTime, $iHeight * 0.5)
_DrawSineSweep($fFreqS, $fFreqE, $fTime, $iHeight * 0.75)
While 1
Sleep(10)
WEnd
Func _DrawSineSweep($fFreqS, $fFreqE, $fTime, $fYOff, $fAmp = 20)
Local $fS, $fX1, $fY1, $fX2, $fY2
$fX1 = 0
$fY1 = $fYOff
Local $iSteps = 2000
Local $fW = $iWidth / $iSteps
Local $fT = $fTime / $iSteps
Local $fTmp, $fVal1, $fVal2
$fVal1 = ($fFreqE - $fFreqS) / ($fTime)
$fVal2 = $fFreqE - $fVal1 * $fTime
$fVal1 /= 2
ConsoleWrite("! " & $fVal1 & @CRLF)
ConsoleWrite("! " & $fVal2 & @CRLF)
For $i = 0 To $iSteps
$fTmp = ($i * $fT)
$fS = Sin($c2PI * $fTmp * ($fVal1 * $fTmp + $fVal2)) * $fAmp
$fX2 = $i * $fW
$fY2 = $fYOff + $fS
DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen_R, "float", $fX1, "float", $fY1, "float", $fX2, "float", $fY2)
DllCall($ghGDIPDll, "int", "GdipDrawEllipse", "handle", $hGfxBuffer, "handle", $hPen_G, "float", $fX2 - 1, "float", $fY2 - 1, "float", 2, "float", 2)
$fX1 = $fX2
$fY1 = $fY2
Next
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc ;==>_DrawSineSweep
Func _DrawSine($fFreq, $fTime, $fYOff, $fAmp = 20)
Local $fS, $fX1, $fY1, $fX2, $fY2
$fX1 = 0
$fY1 = $fYOff
Local $iSteps = 2000
Local $fW = $iWidth / $iSteps
Local $fT = $fTime / $iSteps
Local $fTmp
For $i = 0 To $iSteps
$fTmp = ($i * $fT)
$fS = Sin($c2PI * $fTmp * $fFreq) * $fAmp
$fX2 = $i * $fW
$fY2 = $fYOff + $fS
DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen_R, "float", $fX1, "float", $fY1, "float", $fX2, "float", $fY2)
DllCall($ghGDIPDll, "int", "GdipDrawEllipse", "handle", $hGfxBuffer, "handle", $hPen_G, "float", $fX2 - 1, "float", $fY2 - 1, "float", 2, "float", 2)
$fX1 = $fX2
$fY1 = $fY2
Next
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc ;==>_DrawSine
Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _Exit()
_GDIPlus_PenDispose($hPen_R)
_GDIPlus_PenDispose($hPen_G)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_GDIPlus_BitmapDispose($hBmpBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
GUIDelete($hGui)
Exit
EndFunc ;==>_Exit
Danke
E
Hi
Ich will einen Sinus-Verlauf berechnen z.B.: 110Hz - 440Hz
Das Ergebnis ist leider nicht korrekt: autoit.de/wcf/attachment/21482/
Die ersten 4 Wellen sind richtig und zeigen eine Sinuskurve in 110, 220, 440 u 880Hz
Die letzten 3 sind Sweeps und sollten jeweils bis 440Hz gehen, allerdings ist die Wellenlänge am Ende deutlich kürzer als erwartet.
Weiß jemand, wie man solche Sweeps berechnet?
Ein möglicher Lösungsansatz wäre:
Immer eine ganze Schwingung mit gleicher Frequenz berechnen. Wellenlänge = Lambda = Samplerate / Frequenz.
Die nächste Schwingung beginnt wieder im Nulldurchgang (Step (in meinem Script "$j") beginnt jedesmal wieder bei 0)
Das ist dann aber kein linearer Verlauf mehr!
Es muss doch eine einfache Lösung geben?!
Vielen Dank!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global Const $cPI = ATan(1) * 4
Global Const $c2PI = $cPI * 2
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $iWidth = 800
Global $iHeight = 600
Global $hGui = GUICreate("AutoIt GDI+", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
Global $hPen = _GDIPlus_PenCreate(0xFFFF0000)
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
GUISetState()
Global $tSine
[/autoit] [autoit][/autoit] [autoit]Global $aHz[3][2] = [[2]]
$aHz[1][0] = 110
$aHz[1][1] = 1
$aHz[2][0] = 110
$aHz[2][1] = 2000
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 80)
$aHz[1][0] = 220
$aHz[2][0] = 220
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 160)
$aHz[1][0] = 440
$aHz[2][0] = 440
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 240)
$aHz[1][0] = 880
$aHz[2][0] = 880
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 320)
$aHz[1][0] = 110
$aHz[2][0] = 440
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 400)
Global $aHz[4][2] = [[3]]
$aHz[1][0] = 110
$aHz[1][1] = 1
$aHz[2][0] = 220
$aHz[2][1] = 1000
$aHz[3][0] = 440
$aHz[3][1] = 2000
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 480)
$aHz[1][0] = 110
$aHz[2][0] = 110
$aHz[3][0] = 440
$tSine = _SineSweep($aHz)
_DrawSine($aHz, $tSine, 560)
While 1
Sleep(10)
WEnd
Func _DrawSine($aHz, $tSine, $iY, $fAmp = 16)
Local $iSamples = DllStructGetData($tSine, "Cnt")
Local $tCurve = DllStructCreate("float[" & $iSamples * 2 & "]")
Local $fTmp
For $i = 1 To $iSamples
$fTmp = DllStructGetData($tSine, "Sine", $i) * $fAmp
DllStructSetData($tCurve, 1, ($i - 1) / $iSamples * $iWidth, ($i - 1) * 2 + 1)
DllStructSetData($tCurve, 1, $fTmp + $iY, ($i - 1) * 2 + 2)
Next
DllCall($ghGDIPDll, "uint", "GdipDrawCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPen, "ptr", DllStructGetPtr($tCurve), "int", $iSamples, "float", 0.5)
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To $aHz[0][0]
_GDIPlus_GraphicsDrawString($hGfxBuffer, $aHz[$i][0] & "Hz", $aHz[$i][1] / $iSamples * ($iWidth - 40), $iY - $fAmp - 16)
Next
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc ;==>_DrawSine
Func _SineSweep($aHz, $fRate = 44100.0)
Local $iCnt = $aHz[0][0]
Local $iSamples = $aHz[$iCnt][1]
Local $tSine = DllStructCreate("int Cnt; float Sine[" & $iSamples & "]")
DllStructSetData($tSine, "Cnt", $iSamples)
Local $fHZ_Start, $fHZ_End
Local $iSmp_Start, $iSmp_End
Local $fTmp, $fS
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To $iCnt - 1
$fHZ_Start = $aHz[$i][0]
$fHZ_End = $aHz[$i + 1][0]
ConsoleWrite("> Sweep: " & $fHZ_Start & "Hz -> " & $fHZ_End & "Hz" & " | " & $aHz[$i][1] & " -> " & $aHz[$i + 1][1] & @CRLF)
For $j = $aHz[$i][1] To $aHz[$i + 1][1]
$fTmp = $fHZ_Start + (($fHZ_End - $fHZ_Start) * ($j - $aHz[$i][1]) / ($aHz[$i + 1][1] - $aHz[$i][1]))
ConsoleWrite("! Hz: " & $fTmp & @CRLF)
$fS = Sin($j * $c2PI / ($fRate / $fTmp))
DllStructSetData($tSine, "Sine", $fS, $j)
Next
Next
Return $tSine
EndFunc ;==>_SineSweep
Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _Exit()
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_GDIPlus_BitmapDispose($hBmpBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
GUIDelete($hGui)
Exit
EndFunc ;==>_Exit
Hier eine Funktion um transparente Icons in GDI+ verwenden zu können: [ gelöst ] GDI+ unterschiedliche Icon-Transparenz
E
Für das letzte bisschen Performance hab ich noch eine optimierte Variante anzubieten:
[autoit]Func _StrReplaceIterated($sS)
Local $sRE = StringRegExpReplace($sS, "(\[)(\d+)(\])", "$1" & Chr(1) & "$2" & Chr(1) & "$3")
Local $aS = StringSplit($sRE, Chr(1))
Local $sO = ""
For $i = 1 To $aS[0] - 1 Step 2
$sO &= $aS[$i] & $aS[$i + 1] * 1000
Next
$sO &= $aS[$aS[0]]
Return SetError(0, $aS[0] / 2, $sO)
EndFunc ;==>_StrReplaceIterated
Die Berechnung erfolgt innerhalb der Funktion und funktioniert deshalb nur für diesen Einsatzzweck!
Deshalb ist auch Taz´s Version die bessere!
Taz77: WOW - die Funktion ist wirklich sehr gut!
E
Hi
Hier ein weiterer Ansatz:
[autoit]Func _StrReplaceIterated($_s, $_sPatt, $_sReplFunc)
Local $sRE_Rep = StringRegExpReplace($_s, $_sPatt, Chr(1) & "$1" & Chr(1))
Local $aSplit = StringSplit($sRE_Rep, Chr(1))
Local $sOut = ""
For $i = 1 To $aSplit[0] - 1 Step 2
$sOut &= $aSplit[$i] & Call($_sReplFunc, $aSplit[$i + 1])
Next
$sOut &= $aSplit[$aSplit[0]]
Return SetError(0, $aSplit[0] / 2, $sOut)
EndFunc ;==>_StrReplaceIterated
lgE
Der Rückgabewert einer Inputbox ist vom Typ "String" und muss zuerst ein eine Zahl umgewandelt werden (z.B.: Number, Int, Round).
[autoit]Local $ergebnis
Do
$x = Number(InputBox("X", "Ergebnis der letzten Eingabe:" & @CR & @CR & $ergebnis))
$y = Number(InputBox("Y", "Ergebnis der letzten Eingabe:" & @CR & @CR & $ergebnis))
If $y > $x Then
$ergebnis = $y & " > " & $x
ElseIf $x > $y Then
$ergebnis = $x & " > " & $y
Else
$ergebnis = $x & " = " & $y
EndIf
Until @error = 1 Or $y = ""
E
Was hattest du denn eigentlich machen wollen?
Ich wollte das Logo in 3D machen und an den Kanten sollten Lichteffekte entlanglaufen.
Gibts das auch als Bildschirmschoner :D?
Könnte man leicht draus machen, allerdings sollte man das Script vorher noch etwas optimieren.
Auch interessante Funktionen wie AluBrush, CreateAlu und LightBrush sind vorhanden.
Wie man Aluminium erstellt, hab ich hier gezeigt: GDIPlus gebürstetes Aluminium ;)
Mit der Funktion _CreateAlu_Brush kann man aus diesem Bitmap einen Brush in jedem beliebigen Farbton erstellen.
Ganz interessant sind auch die einzelnen Bilder, aus denen das fertige Bild entsteht - einfach von den Zeilen 76, 135 u 144 jeweils zwei auskommentieren.
E
Hi
Eigentlich wollte ich einen ganz anderen Effekt ausprobieren, hat jedoch leider nicht geklappt...
Dennoch ist das entstandene Script ganz hübsch anzusehen, denke ich
autoit.de/wcf/attachment/20997/
Viel Spaß beim ausprobieren!
#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $aAutoIt = _CreateAutoItLogo()
Global $aAutoIt_Dim = _CalcLogoDim($aAutoIt)
Global $iWidth = $aAutoIt_Dim[8] * 2 + 20
Global $iHeight = $aAutoIt_Dim[9] * 2 + 20
Global $hGui = GUICreate("AutoIt GDI+", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $hDC = _WinAPI_GetDC($hGui)
Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
_WinAPI_DeleteObject($hBMP)
$hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
_GDIPlus_BitmapDispose($hBmpTmp)
Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
GUISetState()
Global $hBmp_Glow
Global $hBmp_Alu = _CreateAlu($aAutoIt_Dim[2] + 11, $aAutoIt_Dim[3] + 11)
Global $hBmp_AutoIt = _CreateAutoItBitmap($aAutoIt, $aAutoIt_Dim, $hBmp_Alu)
Global $aInfo = _CreateInfoBitmap()
Global $hBrush_Light = _CreateLight_Brush($aAutoIt_Dim[2] / 2, 0xBBFFFFFF, 1.2)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While Sleep(10)
_Draw()
WEnd
Func _Draw()
Local Static $fRotate = -30, $fRotateI = 0.33, $fGlow = 0, $fLight = 0
$fRotate += $fRotateI
$fGlow += 0.1
$fLight += 0.011
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, -($aAutoIt_Dim[4] + $aAutoIt_Dim[6] / 2), -($aAutoIt_Dim[5] + $aAutoIt_Dim[7] / 2), True)
_GDIPlus_MatrixRotate($hMatrix, $fRotate, True)
_GDIPlus_MatrixTranslate($hMatrix, ($aAutoIt_Dim[8]), ($aAutoIt_Dim[9]), True)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $aAutoIt_Dim[8] * 2, "int", $aAutoIt_Dim[9] * 2, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Then Return SetError(1, 3, False)
Local $hBMP = $aResult[6]
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBMP)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
_GDIPlus_GraphicsSetTransform($hGfx, $hMatrix)
_GDIPlus_GraphicsDrawImage($hGfx, $hBmp_AutoIt, 0, 0)
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
_GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBMP, 0, 0)
_GDIPlus_BitmapDispose($hBMP)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Then Return SetError(1, 3, False)
Local $hBMP = $aResult[6]
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBMP)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
Global $fScale = 1.007
[/autoit] [autoit][/autoit] [autoit]DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx, "int", 0)
DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfx, "float", -$aAutoIt_Dim[8], "float", -$aAutoIt_Dim[9], "int", 1)
DllCall($ghGDIPDll, "uint", "GdipRotateWorldTransform", "hwnd", $hGfx, "float", $fRotateI + Sin($fGlow) * 0.14, "int", 1)
DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGfx, "float", $fScale, "float", $fScale, "int", 1)
DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfx, "float", $aAutoIt_Dim[8], "float", $aAutoIt_Dim[9], "int", 1)
Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];")
DllStructSetData($tColorMatrix, 1, 1, 1)
DllStructSetData($tColorMatrix, 2, 1, 2)
DllStructSetData($tColorMatrix, 3, 1, 3)
DllStructSetData($tColorMatrix, 4, 0.96, 4)
DllStructSetData($tColorMatrix, 5, 1, 5)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
If @error Then Return SetError(1, 4, False)
Local $hImgAttrib = $aResult[1]
DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGfx, "hwnd", $hBmp_Glow, "int", 0, "int", 0, "int", $iWidth, "int", $iHeight, "int", 0, "int", 0, "int", $iWidth, "int", $iHeight, "int", 2, "ptr", $hImgAttrib, "int", 0, "int", 0)
[/autoit] [autoit][/autoit] [autoit]DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
[/autoit] [autoit][/autoit] [autoit]Local $iInfW = _GDIPlus_ImageGetWidth($aInfo[0])
Local $iInfH = _GDIPlus_ImageGetHeight($aInfo[0])
_GDIPlus_GraphicsDrawImage($hGfxBuffer, $aInfo[0], $iWidth / 2 - $iInfW / 2, $iHeight - $iInfH - 30)
Local $hClone
If Random(0, 300, 1) = 0 Then
$aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $aAutoIt[2], "hwnd*", 0)
$hClone = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hClone, "hwnd", $hMatrix)
Local $hPen = _GDIPlus_PenCreate(0xAA000000,
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen, "hwnd", $hClone)
_GDIPlus_PenDispose($hPen)
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hClone)
EndIf
$aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $aAutoIt[1], "hwnd*", 0)
$hClone = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hClone, "hwnd", $hMatrix)
Local $hPen_Glow = _GDIPlus_PenCreate(0x30FFEEFF, 3)
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen_Glow, "hwnd", $hClone)
_GDIPlus_PenDispose($hPen_Glow)
_GDIPlus_GraphicsDispose($hGfx)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBMP, 0, 0)
_GDIPlus_BitmapDispose($hBmp_Glow)
$hBmp_Glow = $hBMP
DllCall($ghGDIPDll, "uint", "GdipResetLineTransform", "hwnd", $hBrush_Light)
DllCall($ghGDIPDll, "uint", "GdipRotateLineTransform", "hwnd", $hBrush_Light, "float", 80, "int", 1)
DllCall($ghGDIPDll, "uint", "GdipScaleLineTransform", "hwnd", $hBrush_Light, "float", 1 + Sin($fLight) * 0.2, "float", 1 + Sin($fLight) * 0.2, "int", 1)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfxBuffer, "hwnd", $hBrush_Light, "hwnd", $hClone)
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hClone)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfxBuffer, "hwnd", $hBrush_Light, "hwnd", $aInfo[1])
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_MatrixDispose($hMatrix)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
EndFunc ;==>_Draw
Func _CreateAutoItBitmap($aAutoIt, $aAutoIt_Dim, $hBmp_Alu)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $aAutoIt_Dim[2] + 20, "int", $aAutoIt_Dim[3] + 20, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Then Return SetError(1, 3, False)
Local $hBMP = $aResult[6]
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBMP)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
Local $hBrush_Alu_1 = _CreateAlu_Brush($hBmp_Alu, 0.75, 0.8, 0.75)
Local $hBrush_Alu_2 = _CreateAlu_Brush($hBmp_Alu, 0.1, 0.3, 0.8)
Local $hBrush_Alu_3 = _CreateAlu_Brush($hBmp_Alu, 0.64, 0.1, 0.1)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfx, "hwnd", $hBrush_Alu_1, "hwnd", $aAutoIt[1])
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfx, "hwnd", $hBrush_Alu_2, "hwnd", $aAutoIt[4])
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfx, "hwnd", $hBrush_Alu_3, "hwnd", $aAutoIt[5])
_GDIPlus_BrushDispose($hBrush_Alu_1)
_GDIPlus_BrushDispose($hBrush_Alu_2)
_GDIPlus_BrushDispose($hBrush_Alu_3)
Local $aGlowColor[6] = [0, 0, 0x00EEFFEE, 0x00DDFFDD, 0x006688FF, 0x00FF6666]
Local $aGlowSize[6] = [0, 0, 16, 14, 14, 10]
Local $hPen_Glow = _GDIPlus_PenCreate()
DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "hwnd", $hPen_Glow, "int", 1)
For $i = 2 To $aAutoIt[0]
_GDIPlus_PenSetColor($hPen_Glow, BitOR(0x14000000, $aGlowColor[$i]))
For $j = 1 To $aGlowSize[$i] Step 2
_GDIPlus_PenSetWidth($hPen_Glow, $aGlowSize[$i] + 3 - $j)
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen_Glow, "hwnd", $aAutoIt[$i])
Next
_GDIPlus_PenSetWidth($hPen_Glow, 2)
_GDIPlus_PenSetColor($hPen_Glow, BitOR(0xDD000000, $aGlowColor[$i]))
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen_Glow, "hwnd", $aAutoIt[$i])
Next
_GDIPlus_PenDispose($hPen_Glow)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose($hGfx)
[/autoit] [autoit][/autoit] [autoit]Return $hBMP
EndFunc ;==>_CreateAutoItBitmap
Func _CreateInfoBitmap()
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
If @error Then Return SetError(1, 1, False)
Local $hPath = $aResult[2]
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", "AutoIt GDI+ Script by Eukalyptus", "int", -1, "hwnd", $hFamily, "int", 0, "float", 13, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)
DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tBounds), "hwnd", 0, "hwnd", 0)
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tBounds, "X") + 10, -DllStructGetData($tBounds, "Y") + 10, 0)
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
Local $iImgW = DllStructGetData($tBounds, "Width") + 20
Local $iImgH = DllStructGetData($tBounds, "Height") + 20
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iImgW, "int", $iImgH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Then Return SetError(1, 3, False)
Local $hBMP = $aResult[6]
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBMP)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
Local $hPen = _GDIPlus_PenCreate(0x0444FFAA)
DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "hwnd", $hPen, "int", 1)
For $i = 12 To 1 Step -1
_GDIPlus_PenSetWidth($hPen, $i)
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen, "hwnd", $hPath)
Next
_GDIPlus_PenSetWidth($hPen, 1)
_GDIPlus_PenSetColor($hPen, 0xFF88DD88)
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfx, "hwnd", $hPen, "hwnd", $hPath)
Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfx, "hwnd", $hBrush, "hwnd", $hPath)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PenSetWidth($hPen, 2)
DllCall($ghGDIPDll, "uint", "GdipWidenPath", "hwnd", $hPath, "hwnd", $hPen, "hwnd", 0, "float", 0.1)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGfx)
[/autoit] [autoit][/autoit] [autoit]Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2 - $iImgW / 2, $iHeight - $iImgH - 30, 0)
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
Local $aReturn[2]
$aReturn[0] = $hBMP
$aReturn[1] = $hPath
Return $aReturn
EndFunc ;==>_CreateInfoBitmap
Func _CreateLight_Brush($fSize, $iLightColor = 0xAAFFFFFF, $fLightScale = 1.3)
Local $tPointF1 = DllStructCreate("float; float;")
Local $tPointF2 = DllStructCreate("float; float;")
DllStructSetData($tPointF2, 2, $fSize * $fLightScale)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", DllStructGetPtr($tPointF1), "ptr", DllStructGetPtr($tPointF2), "uint", 0, "uint", $iLightColor, "int", 0, "int*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)
Local $hBrush = $aResult[6]
DllCall($ghGDIPDll, "uint", "GdipSetLineSigmaBlend", "hwnd", $hBrush, "float", 0.5, "float", 1)
DllCall($ghGDIPDll, "uint", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", True)
Return $hBrush
EndFunc ;==>_CreateLight_Brush
Func _CreateAlu_Brush($hBmp_Alu, $fRed = 1, $fGreen = 1, $fBlue = 1)
Local $iImgW = _GDIPlus_ImageGetWidth($hBmp_Alu)
Local $iImgH = _GDIPlus_ImageGetHeight($hBmp_Alu)
Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];")
DllStructSetData($tColorMatrix, 1, $fRed, 1)
DllStructSetData($tColorMatrix, 2, $fGreen, 2)
DllStructSetData($tColorMatrix, 3, $fBlue, 3)
DllStructSetData($tColorMatrix, 4, 1, 4)
DllStructSetData($tColorMatrix, 5, 1, 5)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
If @error Then Return SetError(1, 4, False)
Local $hImgAttrib = $aResult[1]
DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTextureIA", "hwnd", $hBmp_Alu, "hwnd", $hImgAttrib, "float", 0, "float", 0, "float", $iImgW, "float", $iImgH, "int*", 0)
If @error Then Return SetError(1, 1, False)
Local $hBrush = $aResult[7]
DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
[/autoit] [autoit][/autoit] [autoit]Return $hBrush
EndFunc ;==>_CreateAlu_Brush
Func _CalcLogoDim($aAutoIt)
Local $aDim[10]
Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $pBounds = DllStructGetPtr($tBounds)
DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $aAutoIt[1], "ptr", $pBounds, "hwnd", 0, "hwnd", 0)
$aDim[0] = DllStructGetData($tBounds, "X")
$aDim[1] = DllStructGetData($tBounds, "Y")
$aDim[2] = DllStructGetData($tBounds, "Width")
$aDim[3] = DllStructGetData($tBounds, "Height")
DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $aAutoIt[3], "ptr", $pBounds, "hwnd", 0, "hwnd", 0)
$aDim[4] = DllStructGetData($tBounds, "X")
$aDim[5] = DllStructGetData($tBounds, "Y")
$aDim[6] = DllStructGetData($tBounds, "Width")
$aDim[7] = DllStructGetData($tBounds, "Height")
$aDim[8] = ($aDim[2] - $aDim[6] / 2) + $aDim[4]
$aDim[9] = ($aDim[3] - $aDim[7] / 2) + $aDim[4]
Return $aDim
EndFunc ;==>_CalcLogoDim
Func _CreateAutoItLogo()
Local $bLogo = "0x6A0000006E2D404317F67B4108CA624333A77B410C9E8143C649C7417BA08F4303B02342CA4C9343F3C38B41A23F9E43D31AF13ECB2CAB43D31AF13E8523BB43D31AF13EAF10C8430797D241AF10C84353016942AF10C843A57DA8429A78BF433E79D442C4ACB34341FAE242F07DBB43B7450D432FF7BF43474B2D432FF7BF43556F4F432FF7BF43C8AB9C43D50A95432198C7436E2D40432198C74381A2AC422198C743D31AF13EC8AB9C43D31AF13E556F4F43D31AF13E4D26CB4281A2AC4233A77B416E2D404333A77B416E2D4043FCD2B343BDE18943AF9AB343BBF9AB43B0829143BBF9AB43556F4F43BBF9AB438FB2F742BDE1894364D55E426E2D404364D55E42C32ED94264D55E42CDCD21428FB2F742CDCD2142556F4F43CDCD2142B0829143C32ED942AF9AB3436E2D4043AF9AB34319730E43D4E5834317D2174326C27A43163121433C0B6E4305842A43444861437FDA36434448614348BD5E439AB76043A5FB6A43D1C06143C4DB6043AFD95443C1D44943F824324326CA404380F52443883E294302C84543F7BE114390A66643CE7EF44288BC8343D4DBCF4288BC8343BD20AB4288BC8343C37D864288BC83431CB9C64296BC5A433B7A03430DF42D43E797234393370143BCA633433B2BD64246634F4392C1D442F24D5F4393370143AF9E7E430DF42D43AEF18E4396BC5A430B9A9E4388BC8343E179814388BC83436EB3484388BC834319730E4388BC8343E52DA043B9B0374279C8A543367737420B63AB43367737429EFDB04336773742582BB443367737427543B443D2B450429EFDB043D2B45042DF17AC43D2B45042192CA743D2B450425B46A243D2B45042E091A3434AE45D426CE3A443C2136B42F834A64300137842A57DA843001378420858B14321A075427E97B24318B67A427D70B3434B4A7E4212EFB343C12F8842C11BB143C12F8842B741AA43C12F8842AD67A343C12F88429E879C43C12F88428C2D9E430719904274CD9F436C1A98425C6DA143D01BA042F255A543D01BA0425DA0B143233DA14209C2B443EF819E42E750BC4317D29742139CBB43D0CC7242C516B743ACBE6642990EBC43DBD15B42BB05BD43BBC61B4241CBB5439D540C423055B243FFFB0442D01BA043C12F084234549B43C12F08421DF49C434F021842FE8D9E43DFD42742E52DA04336773742000303030303030303030303030303030303030303030303830003030303030303030303038300030303030303030303030303030303030303030303030303030383000303030303030303030303030303030303030303030303030303030303030303030303030303830000"
Local $tLogo = DllStructCreate("byte[" & BinaryLen($bLogo) & "];")
DllStructSetData($tLogo, 1, $bLogo)
Local $tCnt = DllStructCreate("uint", DllStructGetPtr($tLogo))
Local $iPathCnt = DllStructGetData($tCnt, 1)
Local $tPathData = DllStructCreate("uint Cnt; float Pnt[" & $iPathCnt * 2 & "]; ubyte Type[" & $iPathCnt & "];", DllStructGetPtr($tLogo))
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath2", "ptr", DllStructGetPtr($tPathData, "Pnt"), "ptr", DllStructGetPtr($tPathData, "Type"), "int", $iPathCnt, "int", 0, "int*", 0)
If @error Then Return SetError(1, 1, False)
Local $hPath = $aResult[5]
Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $pBounds = DllStructGetPtr($tBounds)
DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", $pBounds, "hwnd", 0, "hwnd", 0)
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tBounds, "X") + 10, -DllStructGetData($tBounds, "Y") + 10, 0)
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePathIter", "int*", 0, "hwnd", $hPath)
If @error Then Return SetError(1, 2, False)
Local $hPathIter = $aResult[1]
$aResult = DllCall($ghGDIPDll, "uint", "GdipPathIterGetSubpathCount", "hwnd", $hPathIter, "int*", 0)
If @error Then Return SetError(1, 3, False)
Local $iPathIter = $aResult[2]
Local $aReturn[$iPathIter + 2] = [$iPathIter + 1]
For $i = 1 To $iPathIter
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
If @error Then Return SetError(1, 4, False)
$aReturn[$i + 1] = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipPathIterNextSubpathPath", "hwnd", $hPathIter, "int*", 0, "hwnd", $aReturn[$i + 1], "int*", 0)
Next
DllCall($ghGDIPDll, "uint", "GdipDeletePathIter", "hwnd", $hPathIter)
$aReturn[1] = $hPath
[/autoit] [autoit][/autoit] [autoit]Return $aReturn
EndFunc ;==>_CreateAutoItLogo
Func _CreateAlu($iW, $iH, $iBlurDist = 14, $fBlurTrans = 0.6)
$iBlurDist = Ceiling($iBlurDist)
$iBlurDist += 1 - Mod($iBlurDist, 2)
Local $iOverSize = 0
For $i = 1 To $iBlurDist Step 2
$iOverSize += $i + $i + 1
Next
Local $iWO = $iW + $iOverSize
[/autoit] [autoit][/autoit] [autoit]Local $iNoiseSize = 40
[/autoit] [autoit][/autoit] [autoit]Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iNoiseSize, "int", $iNoiseSize, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
Local $hBmp_Noise = $aResult[6]
Local $hGfx_Noise = _GDIPlus_ImageGetGraphicsContext($hBmp_Noise)
Local $tData = _GDIPlus_BitmapLockBits($hBmp_Noise, 0, 0, $iNoiseSize, $iNoiseSize, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)
Local $iStride = DllStructGetData($tData, "Stride")
Local $iWidth = DllStructGetData($tData, "Width")
Local $iHeight = DllStructGetData($tData, "Height")
Local $pScan0 = DllStructGetData($tData, "Scan0")
Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", $pScan0)
Local $iAmp
For $row = 0 To $iHeight - 1
For $col = 0 To $iWidth - 1
$iAmp = Random(0, 0xFF, 1)
DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift($iAmp, -16), BitShift($iAmp, -8), $iAmp), $row * $iWidth + $col + 1)
Next
Next
_GDIPlus_BitmapUnlockBits($hBmp_Noise, $tData)
[/autoit] [autoit][/autoit] [autoit]$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWO, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
Local $hBmp_Full = $aResult[6]
Local $hGfx_Full = _GDIPlus_ImageGetGraphicsContext($hBmp_Full)
_GDIPlus_GraphicsSetSmoothingMode($hGfx_Full, 2)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Full, "int", 7)
Local $iXOff, $iYOff, $iSizeX, $iSizeY
For $y = 0 To $iH Step $iNoiseSize / 2
For $x = 0 To $iWO Step $iNoiseSize / 2
$iXOff = Random(0, $iNoiseSize / 2, 1)
$iYOff = Random(0, $iNoiseSize / 2, 1)
$iSizeX = $iNoiseSize - $iXOff
$iSizeY = $iNoiseSize - $iYOff
_GDIPlus_GraphicsDrawImageRectRect($hGfx_Full, $hBmp_Noise, $iXOff, $iYOff, $iSizeX, $iSizeY, $x, $y, $iSizeX, $iSizeY)
Next
Next
_GDIPlus_GraphicsDispose($hGfx_Noise)
_GDIPlus_BitmapDispose($hBmp_Noise)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWO, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
Local $hBmp_Full2 = $aResult[6]
Local $hGfx_Full2 = _GDIPlus_ImageGetGraphicsContext($hBmp_Full2)
_GDIPlus_GraphicsSetSmoothingMode($hGfx_Full2, 2)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Full2, "int", 7)
Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];")
DllStructSetData($tColorMatrix, 1, 1, 1)
DllStructSetData($tColorMatrix, 2, 1, 2)
DllStructSetData($tColorMatrix, 3, 1, 3)
DllStructSetData($tColorMatrix, 4, $fBlurTrans, 4)
DllStructSetData($tColorMatrix, 5, 1, 5)
$aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)
Local $hImgAttrib = $aResult[1]
DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
For $i = 1 To $iBlurDist Step 2
DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGfx_Full2, "hwnd", $hBmp_Full, "int", $i, "int", 0, "int", $iWO, "int", $iH, "int", 0, "int", 0, "int", $iWO, "int", $iH, "int", 2, "ptr", $hImgAttrib, "int", 0, "int", 0)
DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGfx_Full, "hwnd", $hBmp_Full2, "int", $i + 1, "int", 0, "int", $iWO, "int", $iH, "int", 0, "int", 0, "int", $iWO, "int", $iH, "int", 2, "ptr", $hImgAttrib, "int", 0, "int", 0)
Next
DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
_GDIPlus_GraphicsDispose($hGfx_Full2)
_GDIPlus_BitmapDispose($hBmp_Full2)
_GDIPlus_GraphicsDispose($hGfx_Full)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
Local $hBmp_Alu = $aResult[6]
Local $hGfx_Alu = _GDIPlus_ImageGetGraphicsContext($hBmp_Alu)
_GDIPlus_GraphicsSetSmoothingMode($hGfx_Alu, 2)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Alu, "int", 7)
_GDIPlus_GraphicsDrawImage($hGfx_Alu, $hBmp_Full, -$iOverSize, 0)
_GDIPlus_BitmapDispose($hBmp_Full)
_GDIPlus_GraphicsDispose($hGfx_Alu)
Return $hBmp_Alu
EndFunc ;==>_CreateAlu
Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _Exit()
For $i = 1 To $aAutoIt[0]
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $aAutoIt[$i])
Next
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $aInfo[1])
_GDIPlus_BitmapDispose($hBmp_Alu)
_GDIPlus_BitmapDispose($hBmp_AutoIt)
_GDIPlus_BitmapDispose($hBmp_Glow)
_GDIPlus_BitmapDispose($aInfo[0])
_GDIPlus_BrushDispose($hBrush_Light)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose($hGfxBuffer)
_WinAPI_SelectObject($hCDC, $hOBJ)
_WinAPI_DeleteObject($hBMP)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hGui, $hDC)
_GDIPlus_Shutdown()
GUIDelete($hGui)
Exit
EndFunc ;==>_Exit
E
Erstmal Danke für die Lorbeeren!
Auch die AutoIt-Structs, aus denen du Daten liest/schreibst gehören 16-Byte-aligned!
Mit dem Alignen hatte ich in der Vergangenheit immer wieder mal Probleme.
Und zwar funktioniert der Code problemlos, solange der ASM-Code "live" kompiliert wird.
Sobald man aber den kompilierten ByteCode benutzt, stürzt das Script plötzlich hin und wieder ab.
Da ich dieses Problem bisher nicht lösen konnte, verwende ich immer movdqu, auch wenn es langsamer ist.
Und das betrifft leider auch die Speicherstelle im Stack!
Zuerst dachte ich, dass ich nur den "CodeBuffer" alignen müsste, aber auch das hat nicht geholfen...
Wenn du die Möglichkeit hast, dann bau die Struct direkt so, dass du immer 16-Byte Blöcke holen kannst
Der Aufbau hängt in diesem Fall von GDIPlus ab; ich lese und schreibe eben in dem Format, damit ich die Daten dann direkt an GDIPlus weitergeben kann.
Im Großen und Ganzen bin ich ja mit meiner Leistung zufrieden.
Ich benötige ja derzeit schon 130% meiner Gehirnleistung um überhaupt die Werte der einzelnen Register im Auge zu behalten.
Für weitere Optimierungsschritte hab ich z.Z leider keinen Slot mehr frei
E
Sehr cooles Script UEZ!
Das bringt mich auf eine Idee - gleich mal ausprobieren
Läuft bei mir übrigens auf WinXP und Win7 ohne Probleme
Mit reinem AutoIt-Code wird z.B. Example_7 nur alle 4 Sekunden geupdated.
Evtl. könnte man den Code auf die doppelte Geschwindigkeit optimieren, aber wirklich flüssig gehts nur mit ASM
Im Anhang der ASM-Code für die Interessierten
E
Ich hab hier eine UDF für euch, mit der man Text auf eine Kurve projizieren kann.
autoit.de/wcf/attachment/20907/
autoit.de/wcf/attachment/20912/
autoit.de/wcf/attachment/20917/
Die Idee dazu stammt von hier: http://www.planetclegg.com/projects/WarpingTextToSplines.html
Im Anhang befindet sich die UDF incl. Beispiele
Die UDF ist noch Beta, deshalb fehlen noch die Funktionsbeschreibungen; Ich hoffe aber, dass die Beispiele trotzdem zu verstehen sind
Viel Spaß beim experimentieren...
Ach ja - läuft nur unter X86.
E
Die Werte liegen zwischen 0 und 1
Das menschliche Gehör arbeitet logarithmisch.
Deshalb sollte man erstens die Werte noch via _BASS_EXT_Level2dB umwandeln.
Und zweitens die Frequenzbänder "anpassen"
Ich hab mal versucht das hier zu erklären: FFT Bass.dll kleiner Lehrgang
#AutoIt3Wrapper_UseX64=n
#include "Bass.au3"
#include "BassExt.au3"
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $sFile = FileOpenDialog("Open...", "", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)")
[/autoit] [autoit][/autoit] [autoit]Global $hGui = GUICreate("FFT", 1034, 220)
GUISetOnEvent(-3, "_EXIT")
Global $cDummy_1 = GUICtrlCreateDummy()
For $i = 1 To 128
GUICtrlCreateProgress(($i - 1) * 8 + 5, 10, 7, 100, 5)
Next
Global $cDummy_2 = GUICtrlCreateDummy()
For $i = 1 To 128
GUICtrlCreateProgress(($i - 1) * 8 + 5, 115, 7, 100, 5)
Next
GUISetState()
_BASS_Startup()
_BASS_Init(0, -1, 44100, 0, "")
Global $hStream = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_SAMPLE_FLOAT)
[/autoit] [autoit][/autoit] [autoit]Global $tFFT = DllStructCreate("float[128];")
Global $pFFT = DllStructGetPtr($tFFT)
Global $fdB, $adB_1[129], $adB_2[129], $iIdx
_BASS_ChannelPlay($hStream, True)
[/autoit] [autoit][/autoit] [autoit]Global $iTimer = TimerInit()
While _BASS_ChannelIsActive($hStream)
If TimerDiff($iTimer) > 25 Then
$iTimer = TimerInit()
_BASS_ChannelGetData($hStream, $pFFT, $BASS_DATA_FFT256)
For $i = 1 To 128
$fdB = _BASS_EXT_Level2dB(DllStructGetData($tFFT, 1, $i)) * 100
If $fdB > $adB_1[$i] Then $adB_1[$i] = $fdB
GUICtrlSetData($cDummy_1 + $i, $adB_1[$i])
$adB_1[$i] -= 4
$iIdx = Round(10 ^ ($i * (Log(128) / Log(10)) / 128))
$fdB = _BASS_EXT_Level2dB(DllStructGetData($tFFT, 1, $iIdx)) * 100
If $fdB > $adB_2[$i] Then $adB_2[$i] = $fdB
GUICtrlSetData($cDummy_2 + $i, $adB_2[$i])
$adB_2[$i] -= 4
Next
EndIf
WEnd
_Exit()
[/autoit] [autoit][/autoit] [autoit]Func _Exit()
_BASS_StreamFree($hStream)
_BASS_Free()
Exit
EndFunc ;==>_Exit
E
Die Daten erhälst du via _BASS_ChannelGetData mit dem entsprechenden Parameter wie etwa: $BASS_DATA_FFT1024.
Im Forum findest du ein paar Beispiele, z.B.: Visualizer - gesammtes Spektrum
E
Hi
Da meine ersten Tests vielversprechend aussahen, hab ich auch eine Funktion geschieben, um Binäre Daten als String zu komprimieren.
Das Endergebnis ist dann doch nicht ganz so rosig, wie ich am anfang dachte
AutoIt3.exe kann ich auf gut 48 % zusammenschrumpfen.
Das ist nicht wirklich viel mehr Kompression, als etwa Andys AutoItOnly Version.
Bei Daten, wo viele gleiche Wiederholungen auftreten (etwa Bitmaps mit großen einfärbigen Flächen), steigt die Kompressionsrate aber enorm.
Das Array 10000 mal 0xFF112233 schrumpft so auf 0.04%
Zugegeben, solche Daten kommen eher selten vor
Und Bitmaps mit großen einfäbigen Flächen sollte man dann doch zuerst als Jpg speichern und dann erst komprimieren...
Nun ja, vielleicht findet ja trotzdem jemand Verwendung dafür...
;#include "ASM.au3"
[/autoit] [autoit][/autoit] [autoit];$hFile = FileOpen(@AutoItExe, 16)
;$bData = FileRead($hFile)
;FileClose($hFile)
;#cs
$iMax = 10000
$tData = DllStructCreate("uint[" & $iMax & "];")
For $i = 1 To $iMax
;DllStructSetData($tData, 1, Random(0, 0xFF, 1), $i)
DllStructSetData($tData, 1, 0xFF112233, $i)
Next
$tByte = DllStructCreate("byte[" & DllStructGetSize($tData) & "];", DllStructGetPtr($tData))
$bData = DllStructGetData($tByte, 1)
#ce
$sComp = _Comp($bData)
$sConst = _CreateConst($sComp)
ClipPut($sConst)
ConsoleWrite(@CRLF)
ConsoleWrite("> Data: " & StringLen($bData) & " " & StringLeft($bData, 1000) & @CRLF)
ConsoleWrite("> Comp: " & StringLen($sComp) & " " & StringLeft($sComp, 1000) & @CRLF)
ConsoleWrite(@CRLF)
ConsoleWrite("! Comp Rate: " & StringFormat("%.2f", StringLen($sComp) * 100 / StringLen($bData)) & " %" & @CRLF)
ConsoleWrite(@CRLF)
$bDeComp = _DeComp($sComp)
_Compare($bData, $bDeComp, "Result")
ConsoleWrite(@CRLF)
Func _DeComp($sComp)
Local $t_ASM_DeCompPrepare = DllStructCreate("byte[138];")
DllStructSetData($t_ASM_DeCompPrepare, 1, "0x8B7424048B7C2408668B063C21762B3C4372182C4388C4C0EC04240F6605333366890783C70283C601EBDD6605101066890783C70283C602EBCE83C601B8000000008A2E80FD007440BA00000000B1000FB65E0180FB32771480FB23720F83C60180EB23D3E380C10409DAEBE383C60180FD52770A83C00183EA017FF8EBC383C00283EA017FF8EBB9C3")
Local $t_ASM_DeCompPMut = DllStructCreate("byte[109];")
DllStructSetData($t_ASM_DeCompPMut, 1, "0x8B7424048B7C24088B54240C8A0683C6013C217602EBF58A2E80FD00744EBB00000000B1000FB646013C3277123C23720E83C6012C23D3E080C10409C3EBE683C60180FD52770C882F83C70183EB017FF6EBC480ED530FB6C5D1E0668B0C0266890F83C70283EB017FF5EBABC3")
Local $t_ASM_DeCompBufCalcSize = DllStructCreate("byte[66];")
DllStructSetData($t_ASM_DeCompBufCalcSize, 1, "0x8B742404B800000000668B1E83C60280FB00742D80FF00742880FB42770A80FF42771483C001EBE180FF42770A0FB6D780EA3301D0EBD20FB6D780EA4301D0EBC8C3")
Local $t_ASM_DeCompBuf = DllStructCreate("byte[182];")
DllStructSetData($t_ASM_DeCompBuf, 1, "0x8B7424048B7C24088B54240C660FEFDB668B0683C6023C000F84970000003C42770E80FC437220662D13436689C1EB2B80FC437209662D43436689C1EB1D662D33336689C1EB14662D3333C0E40408E00FB6C0660F6EE0B501EB090FB6D9F30F6F641A01F30F7F270FB6C501C78A0200E83C3076282C300FB6C0F30F6F7C0201F30F6F740211F30F6F6C0221F30F7F7A01F30F7F7211F30F7F6A2128020FB602F30F7F64020100E8F30F7F5C0201002AE95BFFFFFFC3")
If Not StringRegExp($sComp, "[\x{0023}-\x{FFFF}]*\x{0021}[\x{0023}-\x{FFFF}]{2,}") Then Return SetError(1, 1, False)
Local $iLen = StringLen($sComp)
Local $tComp = DllStructCreate("char[" & $iLen + 1 & "]")
Local $pComp = DllStructGetPtr($tComp)
DllStructSetData($tComp, 1, $sComp)
Local $tPMut = DllStructCreate("word[173];")
Local $pPMut = DllStructGetPtr($tPMut)
Local $aRet = DllCall("user32.dll", "uint", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_DeCompPrepare), "ptr", $pComp, "ptr", $pPMut, "int", 0, "int", 0)
If @error Or Not IsArray($aRet) Then Return SetError(1, 2, False)
Local $iSize = $aRet[0]
Local $tCompBuf = DllStructCreate("byte[" & $iSize & "]; byte[16];")
Local $pCompBuf = DllStructGetPtr($tCompBuf)
DllCall("user32.dll", "none", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_DeCompPMut), "ptr", $pComp, "ptr", $pCompBuf, "ptr", $pPMut, "int", 0)
[/autoit] [autoit][/autoit] [autoit]$aRet = DllCall("user32.dll", "uint", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_DeCompBufCalcSize), "ptr", $pCompBuf, "int", 0, "int", 0, "int", 0)
If @error Or Not IsArray($aRet) Then Return SetError(1, 3, False)
$iSize = $aRet[0]
Local $tDeComp = DllStructCreate("byte[" & $iSize & "]; byte[16];")
Local $pDeComp = DllStructGetPtr($tDeComp)
Local $tBuf = DllStructCreate("byte[65];");[1]BufCnt + [16*3]Buffer + [16]Pad
Local $pBuf = DllStructGetPtr($tBuf)
DllCall("user32.dll", "none", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_DeCompBuf), "ptr", $pCompBuf, "ptr", $pDeComp, "ptr", $pBuf, "int", 0)
[/autoit] [autoit][/autoit] [autoit]Return DllStructGetData($tDeComp, 1)
EndFunc ;==>_DeComp
Func _Comp($bData)
Local $t_ASM_CompBuf = DllStructCreate("byte[335];")
DllStructSetData($t_ASM_CompBuf, 1, "0x8B7424048B7C24088B54240C8B5C2410660F6ECBF30F6F26F30F6F6A01F30F6F7211F30F6F7A21B100660FEFD2660F6FDC660F74DD660FD7C3BB01000000B50085D8740AD1E380C50180FD0F72F2660F7ED338EF7704660F6ED1660F73DD01660F6FC6660F73F80F660FEBE8660F73DE01660F6FC7660F73F80F660FEBF0660F73DF0180C1013A0A72A3660F7ED1660F7ECB0FB6C539D8760288DD80FD02723B80F90F770F6689C86605434366890783C702EB3F80F91F77116689C82C106605433366890783C702EB296689C82C206605334366890783C702EB18660FC5C400B50188C4C0EC04240F6605333366890783C7028A0200E83C3076282C300FB6C0F30F6F7C0201F30F6F740211F30F6F6C0221F30F7F7A01F30F7F7211F30F7F6A2128020FB602F30F7F64020100E8660FEFC0F30F7F440201002A0FB6C501C6660F7ECB29C383FB000F87C2FEFFFFC3")
Local $t_ASM_Comp = DllStructCreate("byte[411];")
DllStructSetData($t_ASM_Comp, 1, "0x8B7424048B7C2408B13383C702B53366890F83C70480C50180FD5372F280C10180F95372E88B7C2408668B0683C60180FC007423662D33330FB6DC0FB6D0C1E307C1E20201D3668B0C1F6683F9FF74056683041F01EBD2B900000000BAFE03000089D6C1E6028B04378B5C37046639D87307891C37894437044A39CA7DE34181F9FF03000072D566BB002166B90000668B176683FA027244668B57028B742404B50088CB80C353668B063C00741780FC0074126639D0750866891E83C601B50183C601EBE280FD00740380C101660FB6D566891783C70480F9AD72B366BAFFFF6689178B74240489F78A0683C6013C00740B3C2176F3880783C701EBECC607008B7424088B7C240C668B166683FA007C3D6683FA007432668B560280FA42771E80FE4277196689D0662D3333C0E40408E03CBC77090443880783C701EB0B6681EA101066891783C70283C604EBBAC607218B74240489F7BA010000008A0683C6013A067424880783C70183FA02721589D3C1EA0483E30F83C323881F83C70183FA0075EBBA0000000083C2013C217202EBCA660FEFC0F30F7F07C3")
If StringRegExp($bData, "[^[:xdigit:]xX]") Then Return SetError(1, 1, False)
Local $iSize = BinaryLen($bData)
If $iSize < 1 Then Return SetError(1, 2, False)
Local $tData = DllStructCreate("byte Data[" & $iSize & "]; byte[16];")
Local $pData = DllStructGetPtr($tData)
DllStructSetData($tData, "Data", $bData)
Local $tComp = DllStructCreate("char[" & $iSize * 2 + 1 & "];")
Local $pComp = DllStructGetPtr($tComp)
Local $tBuf = DllStructCreate("byte[65];");[1]BufCnt + [16*3]Buffer + [16]Pad
Local $pBuf = DllStructGetPtr($tBuf)
DllCall("user32.dll", "none", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_CompBuf), "ptr", $pData, "ptr", $pComp, "ptr", $pBuf, "uint", $iSize)
[/autoit] [autoit][/autoit] [autoit]Local $tPMut = DllStructCreate("word[2048];");32*32*2
Local $pPMut = DllStructGetPtr($tPMut)
Local $tDef = DllStructCreate("char[347];");173*2+1
Local $pDef = DllStructGetPtr($tDef)
DllCall("user32.dll", "none", "CallWindowProcW", "ptr", DllStructGetPtr($t_ASM_Comp), "ptr", $pComp, "ptr", $pPMut, "ptr", $pDef, "int", 0)
[/autoit] [autoit][/autoit] [autoit]Return DllStructGetData($tDef, 1) & DllStructGetData($tComp, 1)
EndFunc ;==>_Comp
Func _CreateConst($sStr, $sName = "sComp")
Local $sConst = 'Global Const $' & $sName & ' = '
Local $aRegExp = StringRegExp($sStr, '^.{' & 4085 - StringLen($sConst) & '}|.{4077}|.*$', 3)
If @error Or Not IsArray($aRegExp) Then Exit
If Not $aRegExp[UBound($aRegExp) - 1] Then ReDim $aRegExp[UBound($aRegExp) - 1]
For $i = 0 To UBound($aRegExp) - 1
Switch $i
Case UBound($aRegExp) - 1
$sConst &= '"' & $aRegExp[$i] & '"'
Case Else
$sConst &= '"' & $aRegExp[$i] & '" & _' & @CRLF & ' '
EndSwitch
Next
Return $sConst
EndFunc ;==>_CreateConst
Func _Compare($bData1, $bData2, $sDesc = "")
Local $iSize1 = BinaryLen($bData1)
Local $iSize2 = BinaryLen($bData2)
Local $iByte1, $iByte2
If (BinaryMid($bData1, 1, $iSize1) = BinaryMid($bData2, 1, $iSize2)) And ($iSize1 = $iSize2) Then
If $iSize1 > 10000 Then
ConsoleWrite("+ " & $sDesc & ": " & BinaryMid($bData1, 1, 10000) & @CRLF)
Else
ConsoleWrite("+ " & $sDesc & ": " & $bData1 & @CRLF)
EndIf
Else
If $iSize1 > 10000 Then
ConsoleWrite("! " & $sDesc & ": " & BinaryMid($bData1, 1, 10000) & @CRLF)
ConsoleWrite("! " & $sDesc & ": " & BinaryMid($bData2, 1, 10000) & @CRLF)
Else
ConsoleWrite("! " & $sDesc & ": " & $bData1 & @CRLF)
ConsoleWrite("! " & $sDesc & ": " & $bData2 & @CRLF)
EndIf
ConsoleWrite("! " & $sDesc & " ")
For $i = 1 To $iSize1
$iByte1 = BinaryMid($bData1, $i, 1)
$iByte2 = BinaryMid($bData2, $i, 1)
If $iByte1 = $iByte2 Then
ConsoleWrite("__")
Else
ConsoleWrite("##")
;ExitLoop
EndIf
Next
ConsoleWrite(@CRLF)
EndIf
EndFunc ;==>_Compare
E
Diese Funktionen rufen doch einfach die "normalen" GDI-Funktionen auf, somit gibt es keinen Unterschied.
Außer, dass man noch einen Tick langsamer ist
Kann aber auch sein, dass ich mich irre und es genau andersrum ist...
Da habe ich dich auf was heiß gemacht...
In der Tat
Der Zeilenübergreifende Algo war einfacher als erwartet:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit];Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\30x30.bmp")
Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Tussie.png")
;Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\earth.bmp")
Global $iImgW = _GDIPlus_ImageGetWidth($hImage)
Global $iImgH = _GDIPlus_ImageGetHeight($hImage)
Global $fScale = 1.8
[/autoit] [autoit][/autoit] [autoit]Global $iWidth = $iImgW * $fScale
Global $iHeight = $iImgH * $fScale
Global $hGui = GUICreate("Test", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfxBuffer, "int", 5)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxBuffer, "int", 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 1)
Global $hBrush = _GDIPlus_BrushCreateSolid(0x88FF0000)
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImageRect($hGfxBuffer, $hImage, 0, 0, $iWidth, $iHeight)
GUISetState()
Global $iTimer = TimerInit()
Global $hPath = _ScanBMP($hImage, $fScale, 0)
ConsoleWrite("! " & TimerDiff($iTimer) & @CRLF)
DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfxBuffer, "hwnd", $hBrush, "hwnd", $hPath)
DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen, "hwnd", $hPath)
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
While Sleep(10)
WEnd
Func _ScanBMP($hBitmap, $fScale = 1, $iMin = 0)
Local $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hBitmap)
If $aPixelFormat[0] <> $GDIP_PXF01INDEXED Then Return SetError(1, 1, False)
Local $iBmpW = _GDIPlus_ImageGetWidth($hBitmap)
Local $iBmpH = _GDIPlus_ImageGetHeight($hBitmap)
Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iBmpW, $iBmpH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $iStride = DllStructGetData($tData, "Stride")
Local $iWidth = DllStructGetData($tData, "Width")
Local $iHeight = DllStructGetData($tData, "Height")
Local $tScan0 = DllStructCreate("byte[" & $iWidth * $iHeight * 4 & "];", DllStructGetData($tData, "Scan0"))
Local $tPixel = DllStructCreate("uint[" & $iWidth * $iHeight & "];")
Local $tSet = DllStructCreate("byte[" & DllStructGetSize($tPixel) & "];", DllStructGetPtr($tPixel))
DllStructSetData($tSet, 1, DllStructGetData($tScan0, 1))
_GDIPlus_BitmapUnlockBits($hBitmap, $tData)
Local $iRect = 0
Local $tRects = DllStructCreate("uint[" & $iWidth * $iHeight * 4 & "];")
Local $iOff, $iPos
Local $iRectX1, $iRectY1, $iRectX2, $iRectY2
Local $iTmpX1, $iTmpY1, $iTmpX2, $iTmpY2
For $y = 0 To $iHeight - 1
$iOff = $y * $iWidth
For $x = 0 To $iWidth - 1
While DllStructGetData($tPixel, 1, $iOff + $x + 1) = 4278190080
[/autoit] [autoit][/autoit] [autoit]$iPos = $iOff + $x
$iTmpX1 = 0
While $x + $iTmpX1 < $iWidth
$iTmpX1 += 1
$iPos += 1
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
ExitLoop
EndIf
WEnd
$iTmpX1 = BitShift($iTmpX1, 1)
$iPos = $iOff + $x + $iTmpX1
$iTmpY1 = 0
While $y + $iTmpY1 < $iHeight
$iTmpY1 += 1
$iPos += $iWidth
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
ExitLoop
EndIf
WEnd
$iTmpY1 = BitShift($iTmpY1, 1)
$iRectX1 = $x + $iTmpX1
$iRectY1 = $y + $iTmpY1
$iRectX2 = $iRectX1
$iRectY2 = $iRectY1
While 1
$iTmpX1 = $iRectX1
$iTmpY1 = $iRectY1
$iTmpX2 = $iRectX2
$iTmpY2 = $iRectY2
;Test RectX1 -= 1
If $iRectX1 > 0 Then
;?####
;?####
;?####
$iRectX1 -= 1
$iPos = $iRectY1 * $iWidth + $iRectX1
For $i = $iRectY1 To $iRectY2
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
$iRectX1 = $iTmpX1
ExitLoop
EndIf
$iPos += $iWidth ;Nächste Zeile
Next
EndIf
;Test RectY1 -= 1
If $iRectY1 > 0 Then
;?????
;#####
;#####
$iRectY1 -= 1
$iPos = $iRectY1 * $iWidth + $iRectX1
For $i = $iRectX1 To $iRectX2
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
$iRectY1 = $iTmpY1
ExitLoop
EndIf
$iPos += 1 ;Nächster Pixel
Next
EndIf
;Test RectX2 += 1
If $iRectX2 < $iWidth Then
;####?
;####?
;####?
$iRectX2 += 1
$iPos = $iRectY1 * $iWidth + $iRectX2
For $i = $iRectY1 To $iRectY2
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
$iRectX2 = $iTmpX2
ExitLoop
EndIf
$iPos += $iWidth ;Nächste Zeile
Next
EndIf
;Test RectY2 += 1
If $iRectY2 < $iHeight Then
;#####
;#####
;?????
$iRectY2 += 1
$iPos = $iRectY2 * $iWidth + $iRectX1
For $i = $iRectX1 To $iRectX2
If DllStructGetData($tPixel, 1, $iPos + 1) <> 4278190080 Then
$iRectY2 = $iTmpY2
ExitLoop
EndIf
$iPos += 1 ;Nächster Pixel
Next
EndIf
If $iRectX1 = $iTmpX1 And $iRectX2 = $iTmpX2 And $iRectY1 = $iTmpY1 And $iRectY2 = $iTmpY2 Then ExitLoop
WEnd
ConsoleWrite("> Rect: " & $iRectX1 & " " & $iRectY1 & " " & $iRectX2 - $iRectX1 + 1 & " " & $iRectY2 - $iRectY1 + 1 & @CRLF)
[/autoit] [autoit][/autoit] [autoit]For $j = $iRectY1 To $iRectY2
$iPos = $j * $iWidth
For $i = $iRectX1 To $iRectX2
DllStructSetData($tPixel, 1, 0, $iPos + $i + 1)
Next
Next
$iTmpX1 = $iRectX2 - $iRectX1 + 1
$iTmpY1 = $iRectY2 - $iRectY1 + 1
If $iTmpX1 > $iMin Or $iTmpY1 > $iMin Then
DllStructSetData($tRects, 1, $iRectX1, $iRect * 4 + 1)
DllStructSetData($tRects, 1, $iRectY1, $iRect * 4 + 2)
DllStructSetData($tRects, 1, $iTmpX1, $iRect * 4 + 3)
DllStructSetData($tRects, 1, $iTmpY1, $iRect * 4 + 4)
$iRect += 1
EndIf
WEnd
Next
Next
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
Local $hPath = $aResult[2]
$aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathRectanglesI", "hwnd", $hPath, "ptr", DllStructGetPtr($tRects), "int", $iRect)
$aResult = DllCall($ghGDIPDll, "uint", "GdipGetPointCount", "hwnd", $hPath, "int*", 0)
ConsoleWrite("! Path Pnt: " & $aResult[2] & @CRLF)
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
ConsoleWrite("! iRect: " & $iRect & @CRLF & @CRLF)
[/autoit] [autoit][/autoit] [autoit]Return $hPath
EndFunc ;==>_ScanBMP
Func _WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _Exit()
_GDIPlus_ImageDispose($hImage)
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGfxBuffer)
_GDIPlus_BitmapDispose($hBmpBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Die Anzahl der Rechtecke lässt sich massiv reduzieren.
Zudem kann man nun auch angeben, ab welcher Größe ein Rechteck überhaupt verwendet werden soll.
Die Umsetzung in ASM scheint mir aber doch etwas zu kompliziert
In FreeBasic sollte es aber relativ einfach sein...
E
Hi
Hier die ASM-Version:
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;#include "ASM.au3"
Global $tASM_BMPtoRect = DllStructCreate("byte[204]") ;reserve Memory for opcodes
DllStructSetData($tASM_BMPtoRect, 1, "0x8B7424048B7C24088B54240CBB01000000660F6EFB660F70F7F3660FEFED660F70E73F660FEFDB660F6FD78B0ABB000000008B0683F8FF741D660F7ED083F8017406660FFEDFEB36660FEFD2660F6FC5660F6FDFEB28660F6FD7660F7ED883F800741B83C301660FFEC4660F70CBCF660FFEC1F30F7F0783C710660FEFDB660FFEEF660F7EE83B42047234660F6FD7660F7ED883F800741B83C301660FFEC4660F70CBCF660FFEC1F30F7F0783C710660FEFDB660FEFED660FFEE6660F6FD783C604490F8769FFFFFF891AC3") ;write opcodes into memory
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit];Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\10x10.bmp")
;Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Tussie.png")
Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Earth.bmp")
Global $iImgW = _GDIPlus_ImageGetWidth($hImage)
Global $iImgH = _GDIPlus_ImageGetHeight($hImage)
Global $fScale = 1
Global $iWidth = $iImgW * $fScale
Global $iHeight = $iImgH * $fScale
Global $hGui = GUICreate("Test", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetBkColor(0xC00000, $hGui)
GUISetState()
Global $iTimer = TimerInit()
_Perforate($hGui, $hImage, $fScale)
ConsoleWrite("! " & TimerDiff($iTimer) & @CRLF)
While Sleep(10)
WEnd
Func _Perforate($hWnd, $hBitmap, $fScale = 1)
;Local $hPath = _BMPtoPath($hImage)
Local $hPath = _BMPtoPathASM($hImage)
If @error Then Return SetError(@error, 1, False)
Local $hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
_GDIPlus_MatrixTranslate($hMatrix, _WinAPI_GetSystemMetrics(7), _WinAPI_GetSystemMetrics(8) + _WinAPI_GetSystemMetrics($SM_CYSIZE) + 1, 1)
DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
_GDIPlus_MatrixDispose($hMatrix)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionPath", "hwnd", $hPath, "int*", 0)
Local $hRegion = $aResult[2]
DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
Local $aSize = WinGetPos(HWnd($hWnd))
Local $tRect = _GDIPlus_RectFCreate(0, 0, $aSize[2], $aSize[3])
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateRegionRect", "ptr", DllStructGetPtr($tRect), "int*", 0)
Local $hRegion_1 = $aResult[2]
Local $aClient = WinGetClientSize(HWnd($hWnd))
$tRect = _GDIPlus_RectFCreate(0, 0, $aClient[0], $aClient[1])
Local $tPnt = DllStructCreate("int X; int Y;")
_WinAPI_ClientToScreen($hWnd, $tPnt)
DllStructSetData($tRect, 1, DllStructGetData($tPnt, "X") - $aSize[0])
DllStructSetData($tRect, 2, DllStructGetData($tPnt, "Y") - $aSize[1])
DllCall($ghGDIPDll, "uint", "GdipCombineRegionRect", "hwnd", $hRegion_1, "ptr", DllStructGetPtr($tRect), "int", 3)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]DllCall($ghGDIPDll, "uint", "GdipCombineRegionRegion", "hwnd", $hRegion, "hwnd", $hRegion_1, "int", 2)
DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion_1)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$aResult = DllCall($ghGDIPDll, "uint", "GdipGetRegionHRgn", "hwnd", $hRegion, "hwnd", $hGraphics, "int*", 0)
Local $hRgn = $aResult[3]
DllCall($ghGDIPDll, "uint", "GdipDeleteRegion", "hwnd", $hRegion)
DllCall('user32.dll', 'long', 'SetWindowRgn', 'hwnd', $hWnd, 'long', $hRgn, 'int', 1)
_WinAPI_DeleteObject($hRegion)
_GDIPlus_GraphicsDispose($hGraphics)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc ;==>_Perforate
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _BMPtoPathASM($hBitmap)
Local $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hBitmap)
If $aPixelFormat[0] <> $GDIP_PXF01INDEXED Then Return SetError(1, 1, False)
Local $iBmpW = _GDIPlus_ImageGetWidth($hBitmap)
Local $iBmpH = _GDIPlus_ImageGetHeight($hBitmap)
Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iBmpW, $iBmpH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $iStride = DllStructGetData($tData, "Stride")
Local $iWidth = DllStructGetData($tData, "Width")
Local $iHeight = DllStructGetData($tData, "Height")
Local $pScan0 = DllStructGetData($tData, "Scan0")
Local $iRect = $iWidth * $iHeight
Local $tRects = DllStructCreate("int[" & $iRect * 4 & "];")
Local $tVal = DllStructCreate("uint Cnt; uint W;")
DllStructSetData($tVal, "Cnt", $iWidth * $iHeight)
DllStructSetData($tVal, "W", $iWidth)
;$_ASSEMBLEIT_FLAG = 0
;_AssembleIt("none", "_ASM_BMPtoRECT", "ptr", $pScan0, "ptr", DllStructGetPtr($tRects), "ptr", DllStructGetPtr($tVal))
DllCall("user32.dll", "none", "CallWindowProcW", "ptr", DllStructGetPtr($tASM_BMPtoRect), "ptr", $pScan0, "ptr", DllStructGetPtr($tRects), "ptr", DllStructGetPtr($tVal), "int", 0)
_GDIPlus_BitmapUnlockBits($hBitmap, $tData)
[/autoit] [autoit][/autoit] [autoit]$iRect = DllStructGetData($tVal, "Cnt")
[/autoit] [autoit][/autoit] [autoit]Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
Local $hPath = $aResult[2]
$aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathRectanglesI", "hwnd", $hPath, "ptr", DllStructGetPtr($tRects), "int", $iRect)
Return $hPath
EndFunc ;==>_BMPtoPathASM
Func _BMPtoPath($hBitmap)
Local $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hBitmap)
If $aPixelFormat[0] <> $GDIP_PXF01INDEXED Then Return SetError(1, 1, False)
Local $iBmpW = _GDIPlus_ImageGetWidth($hBitmap)
Local $iBmpH = _GDIPlus_ImageGetHeight($hBitmap)
Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iBmpW, $iBmpH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $iStride = DllStructGetData($tData, "Stride")
Local $iWidth = DllStructGetData($tData, "Width")
Local $iHeight = DllStructGetData($tData, "Height")
Local $pScan0 = DllStructGetData($tData, "Scan0")
Local $tPixel = DllStructCreate("uint[" & $iWidth * $iHeight & "];", $pScan0)
Local $iRect = $iWidth * $iHeight
Local $tRects = DllStructCreate("int[" & $iRect * 4 & "];")
$iRect = -1
Local $iOff, $iNew = 1, $iIdx
Local $iRectX, $iRectW = 0
For $y = 0 To $iHeight - 1
$iOff = $y * $iWidth
For $x = 0 To $iWidth - 1
Switch DllStructGetData($tPixel, 1, $iOff + $x + 1)
Case 4294967295;0xFFFFFFFF
$iNew = 1
If $iRectW > 0 Then
$iRect += 1
$iIdx = $iRect * 4
DllStructSetData($tRects, 1, $iRectX, $iIdx + 1)
DllStructSetData($tRects, 1, $y, $iIdx + 2)
DllStructSetData($tRects, 1, $iRectW, $iIdx + 3)
DllStructSetData($tRects, 1, 1, $iIdx + 4)
$iRectW = 0
EndIf
Case Else
Switch $iNew
Case 1
$iNew = 0
$iRectX = $x
$iRectW = 1
Case Else
$iRectW += 1
EndSwitch
EndSwitch
Next
$iNew = 1
If $iRectW > 0 Then
$iRect += 1
$iIdx = $iRect * 4
DllStructSetData($tRects, 1, $iRectX, $iIdx + 1)
DllStructSetData($tRects, 1, $y, $iIdx + 2)
DllStructSetData($tRects, 1, $iRectW, $iIdx + 3)
DllStructSetData($tRects, 1, 1, $iIdx + 4)
$iRectW = 0
EndIf
Next
$iRect += 1
_GDIPlus_BitmapUnlockBits($hBitmap, $tData)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
Local $hPath = $aResult[2]
$aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathRectanglesI", "hwnd", $hPath, "ptr", DllStructGetPtr($tRects), "int", $iRect)
Return $hPath
EndFunc ;==>_BMPtoPath
Func _Exit()
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
ASM.au3:
#include <AssembleIt.au3>
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _ASM_BMPtoRECT()
_("use32") ;32Bit!
_("mov esi, dword[esp+4]") ;Scan0
_("mov edi, dword[esp+8]") ;Rects
_("mov edx, dword[esp+12]") ;Val
_("mov ebx, 1")
_("movd xmm7, ebx") ;1,0,0,0
_("pshufd xmm6, xmm7, 0xF3") ;0,1,0,0
_("pxor xmm5, xmm5") ;0,0,0,0
_("pshufd xmm4, xmm7, 0x3F") ;0,0,0,1
_("pxor xmm3, xmm3") ;0,0,0,0
_("movdqa xmm2, xmm7") ;1,0,0,0
;xmm7 = 1,0,0,0 = add X
;xmm6 = 0,1,0,0 = add Y
;xmm5 = 0,0,0,0 = XPos
;xmm4 = 0,0,0,1 = YPos (incl. RectH = 1)
;xmm3 = 0,0,0,0 = RectW
;xmm2 = 1,0,0,0 = New
;xmm1 = shuffle RectW
;xmm0 = 0,0,0,0 = Save
_("mov ecx, [edx]") ;PixelCount
_("mov ebx, 0") ;RectCount
_("_Loop:")
_("mov eax, [esi]") ;load Pixel
_("cmp eax, 0xFFFFFFFF")
_("je _Trans")
_("_Full:")
_("movd eax, xmm2")
_("cmp eax, 1") ;New = 1?
_("je _NewRect")
_("_ContRect:")
_("paddd xmm3, xmm7") ;RectW += 1
_("jmp _FullCont")
_("_NewRect:")
_("pxor xmm2, xmm2") ;New = 0
_("movdqa xmm0, xmm5") ;RectX = XPos
_("movdqa xmm3, xmm7") ;RectW = 1
_("jmp _FullCont")
[/autoit] [autoit][/autoit] [autoit]_("_Trans:")
_("movdqa xmm2, xmm7") ;New = 1
_("movd eax, xmm3")
_("cmp eax, 0") ;RectW > 0
_("je _NoWrite")
_("_Write:")
_("add ebx, 1")
;Xmm0 = XPos, 0, 0, 0
_("paddd xmm0, xmm4") ;Add 0, YPos, 0, 1
_("pshufd xmm1, xmm3, 0xCF") ;RectW -> xmm1 0,0,RectW,0
_("paddd xmm0, xmm1") ;Add 0, 0, RectW, 0
_("movdqu [edi], xmm0")
_("add edi, 16")
_("pxor xmm3, xmm3") ;RectW = 0
_("_NoWrite:")
[/autoit] [autoit][/autoit] [autoit]_("_FullCont:")
[/autoit] [autoit][/autoit] [autoit]_("paddd xmm5, xmm7") ;XPos += 1
_("movd eax, xmm5")
_("cmp eax, [edx+4]") ;XPos > Width
_("jb _SameLine")
_("_NewLine:")
_("movdqa xmm2, xmm7") ;New = 1
_("movd eax, xmm3")
_("cmp eax, 0") ;RectW > 0
_("je _NoWrite1")
_("_Write1:")
_("add ebx, 1") ;RectCount += 1
;Xmm0 = XPos, 0, 0, 0
_("paddd xmm0, xmm4") ;Add 0, YPos, 0, 1
_("pshufd xmm1, xmm3, 0xCF")
_("paddd xmm0, xmm1") ;Add 0, 0, RectW, 0
_("movdqu [edi], xmm0")
_("add edi, 16")
_("pxor xmm3, xmm3") ;RectW = 0
_("_NoWrite1:")
[/autoit] [autoit][/autoit] [autoit]_("pxor xmm5, xmm5") ;XPos = 0
_("paddd xmm4, xmm6") ;YPos += 1
_("movdqa xmm2, xmm7") ;New = 1
_("_SameLine:")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_("add esi, 4")
_("dec ecx")
_("ja _Loop")
_("mov [edx], ebx") ;Save RectCount
_("ret ") ;return
EndFunc ;==>_ASM_BMPtoRECT
autoit.de/wcf/attachment/19802/
Der Code fasst alle nebeneinanderliegene Pixel in einer Zeile zu einem Rechteck(Höhe 1) zusammen.
Besser wäre es natürlich, wenn man auch Zeilenübergreifend zusammen fassen würde, denn je weniger Daten in einer Region sind, desto flüssiger läuft es.
Bei zuvielen Rechtecken kann auch schonmal der PC abkacken...
lgE