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. UEZ

Beiträge von UEZ

  • Random bmp Generator

    • UEZ
    • 17. Dezember 2009 um 09:21
    Zitat von Sen
    Spoiler anzeigen
    [autoit]


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

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

    #Region StartUp
    Opt("GUIOnEventMode", 1)
    _GDIPlus_Startup()
    $Rot = _GDIPlus_PenCreate(0xFFFF0000)
    $Gruen = _GDIPlus_PenCreate(0xFF00FF00)
    $Blau = _GDIPlus_PenCreate(0xFF0000FF)
    #EndRegion StartUp

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

    #Region GUI
    $hGUI = GUICreate("RandomDraw", 640, 480, -1, -1)
    $Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetState(@SW_SHOW)
    #EndRegion GUI

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

    #Region Loop
    For $y = 1 To 479
    For $x = 0 To 639
    $Random = Random(1, 3, 1)
    Switch $Random
    Case 1
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Rot)
    Case 2
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Gruen)
    Case 3
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Blau)
    EndSwitch
    Next
    If GUIGetMsg() = -3 Then ExitFunc()
    Next

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ExitFunc()
    EndSwitch
    WEnd
    #EndRegion Loop

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

    #Region Func's
    Func ExitFunc()
    _GDIPlus_PenDispose($Rot)
    _GDIPlus_PenDispose($Blau)
    _GDIPlus_PenDispose($Gruen)
    _GDIPlus_GraphicsDispose($Graphic)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>ExitFunc
    #EndRegion Func's

    [/autoit]

    Schneller + übersichtlicher :P

    Alles anzeigen


    Da fehlt der Eintrag GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunc").

    Am besten vor GUISetState(@SW_SHOW) plazieren ;)

    Ach ja, und If GUIGetMsg() = -3 Then ExitFunc() benötigst du somit nicht mehr!

    D.h. auch der Inhalt der While Schleife ist überflüssig ->

    While Sleep(50)
    WEnd

    Spoiler anzeigen
    [autoit]


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

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

    #Region StartUp
    Opt("GUIOnEventMode", 1)
    _GDIPlus_Startup()
    $Rot = _GDIPlus_PenCreate(0xFFFF0000)
    $Gruen = _GDIPlus_PenCreate(0xFF00FF00)
    $Blau = _GDIPlus_PenCreate(0xFF0000FF)
    #EndRegion StartUp

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

    #Region GUI
    $hGUI = GUICreate("RandomDraw", 640, 480, -1, -1)
    $Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetOnEvent($GUI_EVENT_CLOSE, "ExitFunc")
    GUISetState(@SW_SHOW)
    #EndRegion GUI

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

    #Region Loop
    For $y = 1 To 479
    For $x = 0 To 639
    $Random = Random(1, 3, 1)
    Switch $Random
    Case 1
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Rot)
    Case 2
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Gruen)
    Case 3
    _GDIPlus_GraphicsDrawLine($Graphic, $x, $y, 1, $y, $Blau)
    EndSwitch
    Next
    Next

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

    While Sleep(50)
    WEnd
    #EndRegion Loop

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

    #Region Func's
    Func ExitFunc()
    _GDIPlus_PenDispose($Rot)
    _GDIPlus_PenDispose($Blau)
    _GDIPlus_PenDispose($Gruen)
    _GDIPlus_GraphicsDispose($Graphic)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>ExitFunc
    #EndRegion Func's

    [/autoit]

    Gruß,
    UEZ

  • Random bmp Generator

    • UEZ
    • 16. Dezember 2009 um 23:54

    Hier ein Beispiel von trancexx:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <Memory.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global Const $STM_SETIMAGE = 370

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

    Global Const $iWidth = 810
    Global Const $iHeight = 470

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

    GUICreate("", $iWidth, $iHeight)
    GUISetOnEvent(-3, "_Quit")
    GUISetBkColor(0)

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

    Global $hPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)

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

    Global $iSize = $iWidth * $iHeight
    Global $tBits = DllStructCreate("int[" & $iSize & "]")
    Global $pBits = DllStructGetPtr($tBits)

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

    Global $hBitmap, $aCall, $iHMsg
    Global $hPicHandle = GUICtrlGetHandle($hPic)

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

    Global $tRandom = DllStructCreate("dword")
    Global $pRandom = DllStructGetPtr($tRandom)

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

    GUISetState()

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

    Global $aRtlRandomEx = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("ntdll.dll"), "str", "RtlRandomEx")
    Global $pRtlRandomEx = $aRtlRandomEx[0]

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

    Global $aRtlMoveMemory = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("kernel32.dll"), "str", "RtlMoveMemory")
    Global $pRtlMoveMemory = $aRtlMoveMemory[0]

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

    Global $aSendMessageW = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("user32.dll"), "str", "SendMessageW")
    Global $pSendMessageW = $aSendMessageW[0]

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

    Global $aDeleteObject = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "DeleteObject")
    Global $pDeleteObject = $aDeleteObject[0]

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

    Global $aCreateBitmap = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "CreateBitmap")
    Global $pCreateBitmap = $aCreateBitmap[0]

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

    Global $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)

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

    Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode)

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

    #Region Assemply
    DllStructSetData($tCodeBuffer, 1, _
    "0x" & _
    "33DB" & _ ; xor ebx, ebx
    "68" & SwapEndian($pRandom) & _ ; push $pRandom
    "B8" & SwapEndian($pRtlRandomEx) & _ ; mov eax, RtlRandomEx
    "FFD0" & _ ; call eax
    "8BCB" & _ ; mov ecx, ebx
    "69C9" & SwapEndian(4) & _ ; imul ecx, 4
    "81C1" & SwapEndian($pBits) & _ ; add ecx, $pBits
    "68" & SwapEndian(3) & _ ; push 3 bytes
    "68" & SwapEndian($pRandom) & _ ; push $pRandom
    "51" & _ ; push ecx
    "B8" & SwapEndian($pRtlMoveMemory) & _ ; mov eax, RtlMoveMemory
    "FFD0" & _ ; call eax
    "43" & _ ; inc ebx
    "81FB" & SwapEndian($iSize) & _ ; cmp ebx, $iSize; <- compare ebx with $iSize
    "75" & Hex(256 - 53, 2) & _ ; jne -53 bytes; <- this is saying go back and do it again if not equal
    "68" & SwapEndian($pBits) & _ ; push $pBits
    "68" & SwapEndian(32) & _ ; push BitsPerPel
    "68" & SwapEndian(1) & _ ; push Planes
    "68" & SwapEndian($iHeight) & _ ; push $iHeight
    "68" & SwapEndian($iWidth) & _ ; push $iWidth
    "B8" & SwapEndian($pCreateBitmap) & _ ; mov eax, CreateBitmap
    "FFD0" & _ ; call eax
    "50" & _ ; push eax
    "68" & SwapEndian(0) & _ ; push IMAGE_BITMAP
    "68" & SwapEndian($STM_SETIMAGE) & _ ; push STM_SETIMAGE
    "68" & SwapEndian($hPicHandle) & _ ; push $hPicHandle
    "B8" & SwapEndian($pSendMessageW) & _ ; mov eax, SendMessageW
    "FFD0" & _ ; call eax
    "50" & _ ; push eax
    "B8" & SwapEndian($pDeleteObject) & _ ; mov eax, DeleteObject
    "FFD0" & _ ; call eax
    "C3" _ ; ret
    )
    #EndRegion Assembly

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

    While 1

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

    #region Assembly

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

    DllCall("user32.dll", "int", "CallWindowProcW", _
    "ptr", $pRemoteCode, _
    "int", 0, _
    "int", 0, _
    "int", 0, _
    "int", 0)

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

    #endregion Assembly

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

    Sleep(10)

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

    WEnd

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

    Func SwapEndian($iValue)
    Return Hex(Binary($iValue))
    EndFunc ;==>SwapEndian

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

    Func _Quit()
    Exit
    EndFunc ;==>_Quit

    [/autoit]


    Mit Inline Assembler :thumbup:

    Sprenger120: Benutze Opt("GUIOnEventMode", 1), damit dein Code schneller läuft!

    Gruß,
    UEZ

    PS: wenn man das Ding lang genug laufen lässt, besteht die Wahrscheinlichkeit ein Bild aus dem Universum der Bilder dargestellt zu bekommen, jedenfalls für einen Augenblick ;)

  • Buttons mit Icon und Label

    • UEZ
    • 16. Dezember 2009 um 23:34

    Sieht super aus! :thumbup:

    Kannst ja mal _GDIPlus_StringFormatSetAlign() dir näher anschauen, um den Text einfacher zu plazieren.

    Gruß,
    UEZ

  • Monochromzeichnen eines Bildes

    • UEZ
    • 16. Dezember 2009 um 20:04
    Zitat von Andy

    es gibt 2 Möglichkeiten der Einbindung von Assemblercode:
    - trancexx (wie sollte es anders sein) hält es mit dem Motto der Frauen, je härter, je besser. Sie codet "zu Fuß", benutzt also keinen Assemblercode, sondern schreibt die Prozessorbefehle direkt per Bits und Bytes in den Speicher und setzt dann den Programmpointer auf diesen Code...crazy!

    Spoiler anzeigen
    [autoit]

    ; by trancexx
    #include <GUIConstantsEx.au3>
    #include <Memory.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global Const $STM_SETIMAGE = 370

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

    Global Const $iWidth = 800
    Global Const $iHeight = 470

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

    GUICreate("", $iWidth, $iHeight)
    GUISetOnEvent(-3, "_Quit")
    GUISetBkColor(0)

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

    Global $hPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight)

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

    Global $iSize = $iWidth * $iHeight
    Global $tBits = DllStructCreate("int[" & $iSize & "]")
    Global $pBits = DllStructGetPtr($tBits)

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

    Global $hBitmap, $aCall, $iHMsg
    Global $hPicHandle = GUICtrlGetHandle($hPic)

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

    Global $tRandom = DllStructCreate("dword")
    Global $pRandom = DllStructGetPtr($tRandom)

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

    GUISetState()

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

    Global $aRtlRandomEx = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("ntdll.dll"), "str", "RtlRandomEx")
    Global $pRtlRandomEx = $aRtlRandomEx[0]

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

    Global $aRtlMoveMemory = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("kernel32.dll"), "str", "RtlMoveMemory")
    Global $pRtlMoveMemory = $aRtlMoveMemory[0]

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

    Global $aSendMessageW = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("user32.dll"), "str", "SendMessageW")
    Global $pSendMessageW = $aSendMessageW[0]

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

    Global $aDeleteObject = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "DeleteObject")
    Global $pDeleteObject = $aDeleteObject[0]

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

    Global $aCreateBitmap = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", _WinAPI_GetModuleHandle("gdi32.dll"), "str", "CreateBitmap")
    Global $pCreateBitmap = $aCreateBitmap[0]

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

    Global $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)

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

    Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode)

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

    #Region Assemply
    DllStructSetData($tCodeBuffer, 1, _
    "0x" & _
    "33DB" & _ ; xor ebx, ebx
    "68" & SwapEndian($pRandom) & _ ; push $pRandom
    "B8" & SwapEndian($pRtlRandomEx) & _ ; mov eax, RtlRandomEx
    "FFD0" & _ ; call eax
    "8BCB" & _ ; mov ecx, ebx
    "69C9" & SwapEndian(4) & _ ; imul ecx, 4
    "81C1" & SwapEndian($pBits) & _ ; add ecx, $pBits
    "68" & SwapEndian(3) & _ ; push 3 bytes
    "68" & SwapEndian($pRandom) & _ ; push $pRandom
    "51" & _ ; push ecx
    "B8" & SwapEndian($pRtlMoveMemory) & _ ; mov eax, RtlMoveMemory
    "FFD0" & _ ; call eax
    "43" & _ ; inc ebx
    "81FB" & SwapEndian($iSize) & _ ; cmp ebx, $iSize; <- compare ebx with $iSize
    "75" & Hex(256 - 53, 2) & _ ; jne -53 bytes; <- this is saying go back and do it again if not equal
    "68" & SwapEndian($pBits) & _ ; push $pBits
    "68" & SwapEndian(32) & _ ; push BitsPerPel
    "68" & SwapEndian(1) & _ ; push Planes
    "68" & SwapEndian($iHeight) & _ ; push $iHeight
    "68" & SwapEndian($iWidth) & _ ; push $iWidth
    "B8" & SwapEndian($pCreateBitmap) & _ ; mov eax, CreateBitmap
    "FFD0" & _ ; call eax
    "50" & _ ; push eax
    "68" & SwapEndian(0) & _ ; push IMAGE_BITMAP
    "68" & SwapEndian($STM_SETIMAGE) & _ ; push STM_SETIMAGE
    "68" & SwapEndian($hPicHandle) & _ ; push $hPicHandle
    "B8" & SwapEndian($pSendMessageW) & _ ; mov eax, SendMessageW
    "FFD0" & _ ; call eax
    "50" & _ ; push eax
    "B8" & SwapEndian($pDeleteObject) & _ ; mov eax, DeleteObject
    "FFD0" & _ ; call eax
    "C3" _ ; ret
    )
    #EndRegion Assembly

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

    ;While 1

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

    #region Assembly

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


    $t=timerinit()
    for $i=1 to 10
    DllCall("user32.dll", "int", "CallWindowProcW", _
    "ptr", $pRemoteCode, _
    "int", 0, _
    "int", 0, _
    "int", 0, _
    "int", 0)
    next
    #endregion Assembly
    $x=timerdiff($t)
    msgbox(0,0,$x)
    Sleep(10)
    while 1
    WEnd

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

    Func SwapEndian($iValue)
    Return Hex(Binary($iValue))
    EndFunc ;==>SwapEndian

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

    Func _Quit()
    Exit
    EndFunc ;==>_Quit

    [/autoit]

    - die zweite Möglichkeit ist "schön" :D
    Sprungmarken, eine "richtige" Assemblersyntax und andere feine Features sind in eine fertige Assembler-UDF eingebaut.

    Spoiler anzeigen
    [autoit]

    #include <ASM.au3>

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

    ; Initial an asm object
    Global $Asm = AsmInit()

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

    Demo1()
    Demo2()
    Demo3()
    Demo4()

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

    Func Demo1()
    ; Demo 1: Using Parameters
    AsmReset($Asm)
    AsmAdd($Asm, "push ebp")
    AsmAdd($Asm, "mov ebp, esp")
    AsmAdd($Asm, "mov eax, [ebp + 08]")
    AsmAdd($Asm, "add eax, [ebp + 0c]")
    AsmAdd($Asm, "pop ebp")
    AsmAdd($Asm, "retn 8")
    ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
    $Ret = MemoryFuncCall("int", AsmGetPtr($Asm), "int", 1, "int", 2)
    MsgBox(0, "Demo 1: Using Parameters", "1 + 2 = " & $Ret[0])
    EndFunc

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

    Func Demo2()
    ; Demo 2: Read Time-Stamp Counter
    AsmReset($Asm)
    AsmAdd($Asm, "push ebp")
    AsmAdd($Asm, "mov ebp, esp")
    AsmAdd($Asm, "rdtsc")
    AsmAdd($Asm, "mov ecx, [ebp + 08]")
    AsmAdd($Asm, "mov [ecx], edx")
    AsmAdd($Asm, "pop ebp")
    AsmAdd($Asm, "retn 4")
    ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
    $start=timerinit()
    $Ret = MemoryFuncCall("uint", AsmGetPtr($Asm), "uint*", 0)
    MsgBox(0, "Demo 2: Read Time-Stamp Counter",timerdiff($start)& " RDTSC = " & Hex($Ret[1]) & Hex($Ret[0], 8))
    Return Hex($Ret[1]) & Hex($Ret[0], 8)
    EndFunc

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

    Func Demo3()
    ; Demo 3: Using Label
    AsmReset($Asm)
    AsmAdd($Asm, "mov eax, 0")
    AsmAdd($Asm, "mov ecx, 10")
    AsmAdd($Asm, "label:")
    AsmAdd($Asm, "inc eax")
    AsmAdd($Asm, "loop @label")
    AsmAdd($Asm, "ret")
    ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
    $Ret = MemoryFuncCall("int", AsmGetPtr($Asm))
    MsgBox(0, "Demo 3: Using Label", "loop label for " & $Ret[0] & " times")
    EndFunc

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

    Func Demo4()
    ; Demo 4: Call AutoIt Func From Assembly
    $AutoItFunc = DllCallbackRegister("AutoItFunc", "int", "")
    AsmReset($Asm)
    AsmAdd($Asm, "call " & DllCallbackGetPtr($AutoItFunc))
    ;AsmAdd($Asm, "shl eax, 1")
    AsmAdd($Asm, "ret")
    ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF)
    $Ret = MemoryFuncCall("int", AsmGetPtr($Asm))
    MsgBox(0, "Demo 4: AutoIt Function", "BitShift return value of AutoItFunc: " & $Ret[0])
    DllCallbackFree($AutoItFunc)
    EndFunc

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

    Func AutoItFunc()
    MsgBox(0, "AutoItFunc", "Called by Inline Assembly")
    Return 1230
    EndFunc

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

    ; Release the asm object
    AsmExit($Asm)
    Exit

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


    Welche man letztendlich nutzt, bleibt jedem selbst überlassen, aber die ASM.au3 wäre mein Favorit.

    Alles anzeigen

    Danke für die Info (ASM.au3 und die Demo dazu kenne ich bereits). Ich dachte er daran, wie man in ASM programmiert, aber ich werde mal googeln! ;)

    Danke,
    UEZ

  • Monochromzeichnen eines Bildes

    • UEZ
    • 16. Dezember 2009 um 17:18
    Zitat von Andy

    Allerdings, ich hatte den Wink schon richtig verstanden :D
    Das schöne an der Arbeit mit den structs ist, daß man die prospeed.dll ohne weiteres sofort einsetzen kann, das ist auch der einzige Grund, warum ich bisher den AutoIt-"Inlineassembler" nicht aktiviere. Gerade was den richtig schnellen Grafikkram betrifft, ist es besser, hier im Forum "den Ball ein wenig flach zu halten".
    Sonst werden die Jungs und Mädelz im "bösen" Forum wieder aufmerksam 8o, und ich bekomme wieder haufenweise PN´s nach Pixelsearch in "hiden fenstas" :rofl:

    AutoIt-"Inlineassembler" - klingt interessant! Hast du was für mich (Tutorials), womit ich einige Sachen in GDI+ beschleunigen kann? trancexx hat ja schon einige sehr interessante Beispiele mit Inline ASM gezeigt, nur mir fehlt ein wenig der Einstieg.
    Für Bots habe ich ehrlich gesagt auch kein Bock was zu machen - einfach uninteressant für mich!

    Danke,
    UEZ

  • RectCollison

    • UEZ
    • 16. Dezember 2009 um 17:11

    Bedenke, dass die Kollisionsabfrage von Rechtecken ausgeht. Wenn du komplexere Objekte hast, wird die Kollisionsabfrage ungenauer!

    Gruß,
    UEZ

  • RectCollison

    • UEZ
    • 16. Dezember 2009 um 17:08

    Du solltest die Funktion nicht ändern, sondern mit den Koordinaten der beiden Objekte füttern, so dass du ein Wert zurück bekommst, ob beide Objekte eine Kollision haben oder nicht!

    Gruß,
    UEZ

  • GDI+ Skript schmiert ab

    • UEZ
    • 16. Dezember 2009 um 15:39
    Spoiler anzeigen
    [autoit]


    #include<GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    _GDIPlus_Startup()
    $hGUI = GUICreate("Form1", 625, 443, 192, 124)
    $Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetState(@SW_SHOW)

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

    $Rot = _GDIPlus_PenCreate (0xFFFF0000)
    $Gruen = _GDIPlus_PenCreate (0xFF00FF00)
    $Blau = _GDIPlus_PenCreate (0xFF0000FF)

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

    _GDIPlus_GraphicsClear($Graphic, 0xFF000000)
    _GDIPlus_GraphicsDrawLine ($Graphic,100,10,2,200, $Rot)
    _GDIPlus_GraphicsDrawLine ($Graphic,100,100,2,200, $Gruen)
    _GDIPlus_GraphicsDrawLine ($Graphic,200,200,2,200, $Blau)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    _GDIPlus_PenDispose($Rot)
    _GDIPlus_PenDispose($Blau)
    _GDIPlus_PenDispose($Gruen)
    _GDIPlus_GraphicsDispose($Graphic)
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
    WEnd

    [/autoit]

    UEZ

  • GDI+ Skript schmiert ab

    • UEZ
    • 16. Dezember 2009 um 15:29

    Guckst du:

    Spoiler anzeigen
    [autoit]


    #include<GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    _GDIPlus_Startup()
    $hGUI = GUICreate("Form1", 625, 443, 192, 124)
    $Graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetState(@SW_SHOW)

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

    $Rot = _GDIPlus_PenCreate (0xFE0000)
    $Blau = _GDIPlus_PenCreate (0x0000FE)
    $Gelb = _GDIPlus_PenCreate (0xFFFF00)

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

    _GDIPlus_GraphicsDrawLine ($Graphic,100,10,2,200)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    _GDIPlus_PenDispose($Rot)
    _GDIPlus_PenDispose($Blau)
    _GDIPlus_PenDispose($Gelb)
    _GDIPlus_GraphicsDispose($Graphic)
    _GDIPlus_Shutdown()
    Exit
    EndSwitch
    WEnd

    [/autoit]

    Gruß,
    UEZ

  • ==> Variable must be of type "Object".:

    • UEZ
    • 16. Dezember 2009 um 11:48

    Der Code kommt mir bekannt vor ;)


    Probier's mal so!

    Spoiler anzeigen
    [autoit]


    ;Coded by UEZ 2009
    #AutoIt3Wrapper_Change2CUI=y
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_UseX64=n
    #include <array.au3>
    Global $server = "localhost"
    If $CmdLine[0] > 0 Then $server = $CmdLine[1]

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

    $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $server & "\root\cimv2")

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

    Membership_Administrators_Local($server)

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

    Func Membership_Administrators_Local($srv)
    If StringUpper($srv) = StringUpper("Localhost") Then $srv = @ComputerName
    Local $function_name = "Members"
    Local $LM_members, $x, $LM_LocalGroup_Name, $type, $colItems2, $LM_local_user, $y, $line, $TimeStamp
    Local $filename_ms = $function_name & "_" & $srv
    Local $filename_error_current = $function_name & "_" & $srv & "_error.log"
    $LM_LocalGroup_Name = "Administrators"
    $colItems = $objWMIService.ExecQuery("Select SID from Win32_Group WHERE Domain='" & $srv & "'", "WQL", 0x30)
    If IsObj($colItems) Then
    For $objItem In $colItems
    If StringUpper($objItem.SID) = StringUpper("S-1-5-32-544") Then $LM_LocalGroup_Name = $objItem.Name
    Next
    EndIf
    $type = ""
    $LM_local_user = ""
    $colItems = $objWMIService.ExecQuery("Select * from Win32_GroupUser Where GroupComponent=""Win32_Group.Domain='" & $srv & "',Name='" & $LM_LocalGroup_Name & "'""", "WQL", 0x30)
    If IsObj($colItems) Then
    For $objItem In $colItems
    If $objItem.PartComponent <> "" Then
    $x = StringSplit($objItem.PartComponent, """")
    $type = StringMid($x[1], StringInStr($x[1], ":Win32_") + 7, (StringInStr($x[1], ".") - (StringInStr($x[1], ":Win32_") + 7)))
    $LM_members &= $srv & ";" & $LM_LocalGroup_Name & ";" & $type & ";" & $x[2] & "\" & $x[4] & ";" & @CRLF
    EndIf
    Next
    EndIf
    ConsoleWrite($LM_members)
    EndFunc ;==>Membership_Administrators_Local

    [/autoit]

    Gruß,
    UEZ

  • ==> Variable must be of type "Object".:

    • UEZ
    • 16. Dezember 2009 um 11:23

    Die Sache ist leider nicht immer so einfach -> [ gelöst ] ObjGet() und IsObj()

    Ich musste ein Error Handler einbauen, damit das Skript erstmal weiterläuft!

    [autoit]


    ...
    Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
    ...
    Func _ErrFunc()
    Return
    EndFunc
    ---

    [/autoit]

    Gru,
    UEZ

  • Monochromzeichnen eines Bildes

    • UEZ
    • 16. Dezember 2009 um 09:43
    Zitat von Andy

    Genau deshalb habe ich ja geschrieben, daß man die in GDI+ "eingebauten" Funktionen für diese speziellen Sachen verwenden soll, WENN sie schneller sind...
    Die von mir geposteten Beispiele zeigen einen direkten Weg zu den Bitmapdaten und haben mit GDI+ nichts zu tun. Obwohl ich mir ehrlich gesagt mit GDI+ einen abgebrochen habe, einzelne Pixel oder Bereiche aus Bildern auszulesen, was aber wahrscheinlich auch daran liegt, daß eine Datei zu öffnen, die Pixeldaten in ein Array einzulesen und weiterzuverarbeiten wesentlich einfacher und auch schneller ist.

    Wir nehmen das Graustufenbild der Mona Lisa und suchen alle Pixel mit einer bestimmten "Farbe" um damit z.B. ein bisschen Steganographie zu machen. Dann wäre es nützlich, einen 1:1 Bildvergleich zu machen und/oder die geänderten Pixel zu finden. Das könnte man mit GDI+ und ein bisschen cleverem Bitblt auch versuchen, allerdings bekommt man so weder Position noch Farbe der Pixel, sondern hat wieder ein weiteres "DifferenzBild".
    Wie bekommt man Informationen aus verrauschten Bildern einer Webcam? Wie lese ich den "Text" per OCR aus einem Bild? Alles Anwendungen, bei denen man direkt auf die Rohdaten zugreifen muß.... und einem GDI+ i.d.R. sehr wenig bringt...

    Na ändere doch im von UEZ geposteten Script einfach die Parameter. Schwarz/weiß ist doch nur die extremste Form der Graustufen.
    Oder füge in meinem Script (habe extra eine Leerzeile gelassen^^) in Zeile 27 ein:

    [autoit]

    if $grau<128 then
    $grau = 0
    Else
    $grau=255
    endif

    [/autoit]
    Alles anzeigen

    Anmerkung: mit dem Benchmark wollte ich nur den Geschwindigkeitsunterschied darstellen und NICHT, dass dein Code irgendwie schlecht/schlechter ist als das GDI+ Beispiel!

    Je nach Anwendung kann man sich ja den entstprechenden Code aussuchen!

    Gruß,
    UEZ

  • Bild in die .exe machen

    • UEZ
    • 15. Dezember 2009 um 23:35

    Schau' mal hier nach: http://www.autoitscript.com/forum/index.php?showtopic=51103 oder hier: http://www.autoitscript.com/forum/index.php?showtopic=77430 .

    Gruß,
    UEZ

  • Monochromzeichnen eines Bildes

    • UEZ
    • 15. Dezember 2009 um 23:29
    Zitat von Andy

    Hi,
    ja, habe eine relativ schnelle Lösung(en) im engl. Forum gepostet, Zedna meinte sogar, ich solle meine Beispiele mal zusammenfassen und im dortigen Example-Forum publik machen....na schaumamal....

    Man muß die Dateien nicht unbedingt "sichtbar" machen, die Operationen direkt in der Bitmap sind wesentlich schneller und auch unkomplizierter (m.E.) als GDI+ (obschon man auch schon bei GDI+ auf "fertige" Funktionen zurückgreifen kann.
    Ich habe Dein "Bild nach Schwarzweiß" mal als Beispiel verwendet:
    Mona Lisa downloaden und im scriptverzeichnis speichern

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GDIPlusConstants.au3>
    #include <StructureConstants.au3>
    #include <WinAPI.au3>
    ; quick and dirty....
    Global $stride, $ptr, $pixeldata
    global $bitmapfile1, $width1, $height1, $stride1, $pbitmap1
    global $bitmapfile2, $width2, $height2, $stride2, $pbitmap2
    local $numberdiff = 0 ;number of differences between the 2 pics

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

    $pic1 = "mona-lisa.jpg" ;the image....24bit per pixel, could be a JPG which you want to have gray
    $pic3 = "grey.bmp" ;a bitmapfile with the greyscale

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

    $t=timerinit()
    _GDIPlus_Startup()
    $pixelstruct1 = getbmpdata($pic1, $width1, $height1, $stride1, $pbitmap1) ;get all data from file

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

    $lenght = DllStructGetSize($pixelstruct1) ;get lenght of bitmapdata
    $pixelstruct3 = dllstructcreate("ubyte["&$lenght&"]")
    ;compare
    for $i=1 to $lenght step 3
    $B=dllstructgetdata($pixelstruct1,1,$i) ;Farbanteil B
    $G=dllstructgetdata($pixelstruct1,1,$i+1) ;Farbanteil G
    $R=dllstructgetdata($pixelstruct1,1,$i+2) ;Farbanteil R
    $grau=int(($b+$g+$R)/3)

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

    dllstructsetdata($pixelstruct3,1,$grau,$i) ;write the difference into the difference-file, bottom-up isnt funny but we´ll mirror it later :o)
    dllstructsetdata($pixelstruct3,1,$grau,$i+1) ;write the difference into the difference-file, bottom-up isnt funny but we´ll mirror it later :o)
    dllstructsetdata($pixelstruct3,1,$grau,$i+2) ;write the difference into the difference-file, bottom-up isnt funny but we´ll mirror it later :o)
    next

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

    $head=DllStructcreate("ubyte[54]")
    ;lets create a bitmapfile with the given data
    $Bmpheader = DllStructCreate("align 1;char BM[2];uint Size;uint res;uint Offset;uint BMHI;uint Width;uint Height;short Planes;short BPP;uint BIcomp;int SizeImg;uint reshor;uint resver;uint col;uint colused", dllstructgetptr($head)) ;struct of bytes = header of bitmap #1
    ;fill struct(bitmapheader) with data
    DllStructSetData($bmpheader,"BM","BM")
    DllStructSetData($bmpheader,"Size",54+$lenght)
    DllStructSetData($bmpheader,"Offset",54)
    DllStructSetData($bmpheader,"BMHI",40)
    DllStructSetData($bmpheader,"Width",$width1)
    DllStructSetData($bmpheader,"Height",-$height1) ;negativ because "bottom up"
    DllStructSetData($bmpheader,"Planes",1)
    DllStructSetData($bmpheader,"BPP",24)
    DllStructSetData($bmpheader,"BIcomp",0)
    DllStructSetData($bmpheader,"SizeImg",$lenght)

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

    $header = dllstructgetdata($head,1) ;headerdata
    $pixeldata = stringtrimleft(DllStructGetData($pixelstruct3, 1),2) ;pixeldata
    $bitmap = $header&$pixeldata ;all together is the bitmap-file

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

    $filehandle = FileOpen($pic3, 18) ;write file
    FileWrite($filehandle,BinaryToString($bitmap))
    FileClose($filehandle)

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

    _GDIPlus_ImageDispose($pBitmap1) ;not in the function, because ImageDispose destroys the struct
    ;_GDIPlus_ImageDispose($pBitmap2)
    $m=timerdiff($t)/1000

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

    ;lets have a look what we have done...
    GUICreate("Pic2Gray "&$width1&"x"&$height1&" = "&$width1*$Height1&" Pixel in "&int($m)&" Seconds => "&int($width1*$Height1/$m)&" Pixel/Second",800,500)
    GUICtrlCreatePic($pic1, 10, 10, 350, 350 / $width1 * $height1)
    GUICtrlCreatePic($pic3, 400, 10, 350, 350 / $width1* $height1)
    GUISetState()

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

    Do
    Until GUIGetMsg() = -3

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

    Func getbmpdata($bmpfile, ByRef $width, ByRef $height, ByRef $stride, Byref $pbitmap) ;returns a struct with the data of the pixel
    $pbitmap = _GDIPlus_BitmapCreateFromFile($bmpfile)
    ;_GDIPlus_BitmapLockBits gibt $tagGDIPBITMAPDATA-Struktur zurück
    $BitmapData = _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB)
    If @error Then MsgBox(0, "", "Error locking region " & @error)
    $stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.
    $width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap.
    $height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap.
    ;$pixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap
    $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap.
    $pixeldata = DllStructCreate("ubyte[" & (Abs($stride) * ($height)) & "]", $Scan0)
    $BMPData = DllStructGetData($pixeldata, 1)
    _WinAPI_DeleteObject($pbitmap)
    _GDIPlus_BitmapUnlockBits($pBitmap, $BmpData)
    ;_GDIPlus_ImageDispose($pBitmap) ;destroys the pixeldatastruct, have to be done at end of the script!
    return $pixeldata
    EndFunc ;==>getbmpdata

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

    Das von UEZ gepostete Beispiel benutzt z.B. eins dieser in GDI+ "eingebauten" Features, in diesem Fall die Beeinflussung der Farben. Um aber in eine(r) Datei zu "malen" bzw einzelne Bytes zu lesen/beeinflussen muß man schauen, welche Funktion am besten "hinhaut".

    Alles anzeigen


    Ich war so frei und habe dein Beispiel gegen das GDI+ laufen lassen -> deins 3s. und GDI+ 45ms!

    Gruß,
    UEZ

  • Monochromzeichnen eines Bildes

    • UEZ
    • 15. Dezember 2009 um 21:34

    Hier ein Beispiel, um ein Bild in Graustufen umzuwandeln (ist aus dem engl. Forum)!

    Spoiler anzeigen
    [autoit]


    ;http://www.autoitscript.com/forum/index.ph…ndpost&p=513472
    #Include <GDIPlus.au3>

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

    _GDIPlus_Startup()

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

    $img = FileOpenDialog("Select an image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.gif)", 1)

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

    $hImage1 = _GDIPlus_ImageLoadFromFile($img)
    $hImage2 = _GDIPlus_ImageGreyscale($hImage1)
    $ext = StringMid($img, StringLen($img) -2)
    $sCLSID = _GDIPlus_EncodersGetCLSID ($ext)
    _GDIPlus_ImageSaveToFileEx($hImage2, StringMid($img, 1, StringLen($img) - 4) & "_grey." & $ext, $sCLSID)
    $iwx = _GDIPlus_ImageGetWidth($hImage2)
    $iwy = _GDIPlus_ImageGetHeight($hImage2)
    $hGUI = GUICreate("Convert image to greyscale by Siao", $iwx, $iwy)
    GUISetState()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iwx, $iwy)

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

    While GUIGetMsg() <> -3 * Sleep(50)
    WEnd

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

    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)

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

    _GDIPlus_ShutDown()
    Exit

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

    ;; _GDIPlus_ImageGreyscale()
    ;; Creates a greyscale copy of Image object and returns its handle. To destroy it, use _GDIPlus_ImageDispose() or _GDIPlus_BitmapDispose()
    Func _GDIPlus_ImageGreyscale(Const ByRef $hImage)
    Local $tColorMatrix, $x, $hImgAttrib, $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage), $hGraphics, $hGraphics2, $hBitmap
    ;;create color matrix data
    $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]")
    ;greyscale values:
    $x = DllStructSetData($tColorMatrix, 1, 0.30, 1) * DllStructSetData($tColorMatrix, 1, 0.30, 2) * DllStructSetData($tColorMatrix, 1, 0.30, 3) * _
    DllStructSetData($tColorMatrix, 2, 0.59, 1) * DllStructSetData($tColorMatrix, 2, 0.59, 2) * DllStructSetData($tColorMatrix, 2, 0.59, 3) * _
    DllStructSetData($tColorMatrix, 3, 0.11, 1) * DllStructSetData($tColorMatrix, 3, 0.11, 2) * DllStructSetData($tColorMatrix, 3, 0.11, 3) * _
    DllStructSetData($tColorMatrix, 4, 1.00, 4) * DllStructSetData($tColorMatrix, 5, 1.00, 5)
    ;;create an image attributes object and update its color matrix
    $hImgAttrib = _GDIPlus_ImageAttributesCreate()
    _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, 1, DllStructGetPtr($tColorMatrix))
    ;;copy image
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hGraphics2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    ;;draw original into copy with attributes
    _GDIPlus_GraphicsDrawImageRectRectEx($hGraphics2, $hImage, 0, 0, $iW, $iH, 0, 0, $iW, $iH, 2, $hImgAttrib)
    ;;clean up
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hGraphics2)
    _GDIPlus_ImageAttributesDispose($hImgAttrib)

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

    Return $hBitmap
    EndFunc

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

    ;;;;; other GDIPlus wrappers ;;;;;

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

    #cs
    _GDIPlus_ImageAttributesSetColorMatrix()
    Sets ColorMatrix of ImageAttributes object
    Parameters:
    $hImgAttrib = ImageAttributes object
    $iColorAdjustType = can be:
    ColorAdjustTypeDefault = 0
    ColorAdjustTypeBitmap = 1
    ColorAdjustTypeBrush = 2
    ColorAdjustTypePen = 3
    ColorAdjustTypeText = 4
    ColorAdjustTypeCount = 5
    ColorAdjustTypeAny (Reserved) = 6
    $pColorMatrix = pointer to ColorMatrix structure
    $pGrayMatrix = pointer to GreyMatrix structure
    $iColorMatrixFlags = can be:
    ColorMatrixFlagsDefault = 0
    ColorMatrixFlagsSkipGrays = 1
    ColorMatrixFlagsAltGray = 2
    Return value: True/False
    #ce
    Func _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, $iColorAdjustType, $pColorMatrix = 0, $pGrayMatrix = 0, $iColorMatrixFlags = 0)
    Local $fEnable = 1, $aResult = DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr",$hImgAttrib, "int",$iColorAdjustType, _
    "int",$fEnable, "ptr",$pColorMatrix, "ptr",$pGrayMatrix, "int",$iColorMatrixFlags)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc

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

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

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

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

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

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

    [/autoit]

    Gruß,
    UEZ

    PS: hatte das Speichern nicht richtig durchdacht :rolleyes:

  • DllStructCreate() und DLLCall()

    • UEZ
    • 14. Dezember 2009 um 15:50

    Danke progandy!


    Hier meine Version:

    Spoiler anzeigen
    [autoit]


    If Not FileExists(@ScriptDir & "\GetCoreTempInfo.dll") Or Not ProcessExists("Core Temp.exe") Then
    MsgBox(16,"Error", "Core Temp.exe läuft und/oder GetCoreTempInfo.dll existiert nicht", 20)
    Exit
    EndIf
    $dll = DllOpen(@ScriptDir & "\GetCoreTempInfo.dll")
    $CORE_TEMP_SHARED_DATA = DllStructCreate("uint uiLoad[256];uint uiTjMax[128];uint uiCoreCnt;uint uiCPUCnt;float fTemp[256];float fVID;float fCPUSpeed;float fFSBSpeed;float fMultipier;char sCPUName[100];ubyte ucFahrenheit;ubyte ucDeltaToTjMax")
    $call = DllCall($dll, "int", "fnGetCoreTempInfoAlt", "ptr", DllStructGetPtr($CORE_TEMP_SHARED_DATA))

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

    $CPU_Name = DllStructGetData($CORE_TEMP_SHARED_DATA, "sCPUName")
    $CPU_Speed = Round(DllStructGetData($CORE_TEMP_SHARED_DATA, "fCPUSpeed"),0)
    $CPU_Cores = DllStructGetData($CORE_TEMP_SHARED_DATA, "uiCoreCnt")
    $CPU_FSB_Speed = Round(DllStructGetData($CORE_TEMP_SHARED_DATA, "fFSBSpeed"), 0)
    $CPU_Multiplicator = DllStructGetData($CORE_TEMP_SHARED_DATA, "fMultipier")
    $CPU_Temp = ""
    For $i = 1 To DllStructGetData($CORE_TEMP_SHARED_DATA, 'uiCoreCnt')
    $CPU_Temp &= DllStructGetData($CORE_TEMP_SHARED_DATA, "fTemp", $i) & ","
    Next
    $CPU_Temp = StringMid($CPU_Temp, 1 , StringLen($CPU_Temp) - 1)

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

    MsgBox(0,"Core Temp", _
    "CPU Name: " & $CPU_Name & @CRLF & _
    "CPU Speed: " & $CPU_Speed & " MHz" & @CRLF & _
    "CPU Cores: " & $CPU_Cores & @CRLF & _
    "CPU FSB Speed: " & $CPU_FSB_Speed & " MHz" & @CRLF & _
    "CPU Multiplicator: " & $CPU_Multiplicator & @CRLF & _
    "CPU Temp: " & $CPU_Temp & " C")
    $CORE_TEMP_SHARED_DATA = 0
    DllClose($dll)

    [/autoit]

    UEZ

  • DllStructCreate() und DLLCall()

    • UEZ
    • 14. Dezember 2009 um 15:39
    Zitat von Schnitzel

    UEZ im Monolog :rofl:

    Manchmal rede ich mit mir selbst! :D

    UEZ

  • DllStructCreate() und DLLCall()

    • UEZ
    • 14. Dezember 2009 um 15:35

    Hab's: $CPU_Temp = DllStructGetData($CORE_TEMP_SHARED_DATA, "fTemp", [index])

    Wie viele Indices wurden benutzt? Kann man das herausbekommen?

    UEZ

  • DllStructCreate() und DLLCall()

    • UEZ
    • 14. Dezember 2009 um 15:31

    Wie bekomme ich alle Werte für float fTemp[256] zurück?

    $CPU_Temp = DllStructGetData($CORE_TEMP_SHARED_DATA, "fTemp") liefert mir nur ein Wert zurück, erwarte aber 2 Werte!

    $CPU_Temp ist kein Array!

    Danke,
    UEZ

  • DllStructCreate() und DLLCall()

    • UEZ
    • 14. Dezember 2009 um 14:47
    Zitat von Ahnungslos

    beim drüberschaun ist mir auch gerade noch aufgefallen:
    müsste es nicht statt char byte und statt uchar ubyte heißen?

    edit: C++ hab ich auch mal begonnen und sehr schnell das Interessa dran verloren,
    find Nasm da toller, nur leider meckert mein Vierenscanner einige Programme danach an 8|

    ASM ist auch interessant, könnte es für einige zeitkritische Operationen in GDI+ benutzen, wenn ich nur ASM könnte!

    Gruß,
    UEZ

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™