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

  • GDI Plus Array

    • UEZ
    • 6. August 2012 um 14:06

    Hi Ilse,

    leider hatte ich keine Zeit was zu basteln. :(

    Ich habe mal den Basic Image Editor aus dem Windows Screenshooter extrahiert. Dort kannst du u.a. auch Texte auf das Bild zeichnen und rotieren (linke Maustaste gedrückt halten und Maus bewegen).

    Vielleicht hilft die das Ding weiter. Ich weiß, dass es für deine Zwecke überdimensioniert ist, aber was soll's...

    Gruß,
    UEZ

    Dateien

    Basic Image Editor.au3 124,51 kB – 199 Downloads
  • Autoit zu C++ konverter

    • UEZ
    • 5. August 2012 um 15:41

    Ok, vielleicht habe ich " Autoit zu c++ konverter" falsch verstanden.

    Was ist genau mit " Autoit zu c++ konverter" gemeint?

    Gruß,
    UEZ

  • GDI+ Spielerei: Rolle aus Rechtecken

    • UEZ
    • 4. August 2012 um 12:03

    Na ja, Off-Topic ist eher für Themen, die sonst nichts mit Coding zu tun haben. Egal wie "klein" dein Beispiel Skript ist, sollte aber in Skripte liegen. ;)

    Gruß,
    UEZ

  • GDI+ Spielerei: Rolle aus Rechtecken

    • UEZ
    • 3. August 2012 um 01:05
    Zitat von Marsi


    ...
    Die Idee habe ich von einer alten Demo (sowas wie die 64k Demos usw).
    Hier ein Beispiel dazu: http://www.stpe.se/javascript/rasterbar.php
    ...

    Ich hatte ein bissl Zeit und habe mal das JavaScript portiert:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2012 build 2012-08-03
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_Tidy_Stop_OnError=n
    #AutoIt3Wrapper_UseUpx=y
    #AutoIt3Wrapper_UPX_Parameters=--best --lzma
    #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
    #include <Array.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    Opt('GUIOnEventMode', 1)
    Opt("MustDeclareVars", 1)

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

    _GDIPlus_Startup()
    Global Const $iW = 640, $iH = 480
    Global $sGUIText = "Rotating Raster Bars (C64 Style) by UEZ 2012 / FPS: "
    Global Const $hGUI = GUICreate($sGUIText, 640, 480)
    GUISetState()

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

    #region init GDI+
    Global Const $hBitmap = _WinAPI_CreateDIB($iW, $iH)
    Global Const $hDC = _WinAPI_GetDC($hGUI)
    Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
    Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hBitmap)
    Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
    Global Const $hBrush = _GDIPlus_BrushCreateSolid(0x40000000)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
    #endregion
    Global Const $fPI = ACos(-1)
    Global Const $f2PI = 2 * ACos(-1)
    Global Const $fRad = ACos(-1) / 180
    Global Const $fYPos = $iH / 2
    Global Const $fSpeed = 0.3
    Global Const $fRadius = 150
    Global Const $fZSize = 20
    Global Const $iSize = 100, $iS2 = $iSize / 2
    Global $aBitmaps[3][4], $e, $r, $j, $k, $l , $z = 0, $iFPS = 0
    Global $iUb = UBound($aBitmaps) - 1

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

    For $e = 0 To $iUb
    $r = Random(3, 12, 1)
    $aBitmaps[$e][0] = CreateBar($r, $iW, $iSize, "0xFF" & Hex(Random(0x0, 0xFFFFFF, 1), 6))
    $aBitmaps[$e][1] = $fYPos
    $aBitmaps[$e][2] = Sin($e * $fRad) * 360 / ($iUb + 1)
    Next

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

    GUISetOnEvent($GUI_EVENT_CLOSE , "_Exit")
    AdlibRegister("FPS", 1000)

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

    While Sleep(10)
    DllCall($ghGDIPDll, "int", "GdipFillRectangleI", "handle", $hGraphic, "handle", $hBrush, "int", 0, "int", 0, "int", $iW, "int", $iH) ;_GDIPlus_GraphicsFillRect()
    For $j = 0 To $iUb
    $k = Sin($fRad * $z + $aBitmaps[$j][2]) * $fRadius
    $aBitmaps[$j][3] = Cos(-270 + $fRad * $z + $aBitmaps[$j][2])
    $aBitmaps[$j][1] = $fYPos + $k - $iS2
    DllCall($ghGDIPDll, "int", "GdipDrawImageRect", "handle", $hGraphic, "handle", $aBitmaps[$j][0], "float", 0, "float", $aBitmaps[$j][1], "float", $iW, "float", $iSize + $aBitmaps[$j][3] * $fZSize)
    $z += $fSpeed
    Next
    _ArraySort($aBitmaps, 0, 0, 0, 3)
    DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hDC, "int", 0, "int", 0, "int", $iW, "int", $iH, "handle", $hDC_backbuffer, "int", 0, "int", 0, "dword", $SRCCOPY) ;_WinAPI_BitBlt()
    $iFPS += 1
    WEnd

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

    Func CreateBar($iStep, $iW, $iH, $iColor, $iBoost = 3)
    Local Const $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    Local Const $hBitmap = $aResult[6]
    Local Const $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local Const $hBrush = _GDIPlus_BrushCreateSolid(0x00000000)
    Local $i, $y = 0
    For $x = 0 To $iH / 2 Step $iStep
    _GDIPlus_BrushSetSolidColor($hBrush, CalcColor($iColor, $iBoost * $x))
    _GDIPlus_GraphicsFillRect($hCtx, 0, $y, $iW, $iStep, $hBrush)
    $y += $iStep
    Next
    For $x = $iH / 2 - $iStep To 0 Step -$iStep
    _GDIPlus_BrushSetSolidColor($hBrush, CalcColor($iColor, $iBoost * $x))
    _GDIPlus_GraphicsFillRect($hCtx, 0, $y, $iW, $iStep, $hBrush)
    $y += $iStep
    Next
    _GDIPlus_GraphicsDispose($hCtx)
    _GDIPlus_BrushDispose($hBrush)
    Return $hBitmap
    EndFunc

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

    Func CalcColor($iColor, $iStep)
    Local Const $iA = Hex(BitAND(0xFF, BitShift($iColor, 24)), 2)
    Local Const $iR = Hex(Min(BitAND(0xFF, BitShift($iColor, 16)) + Int($iStep), 0xFF), 2)
    Local Const $iG = Hex(Min(BitAND(0xFF, BitShift($iColor, 8)) + Int($iStep), 0xFF), 2)
    Local Const $iB = Hex(Min(BitAND(0xFF, $iColor) + Int($iStep), 0xFF), 2)
    Return "0x" & $iA & $iR & $iG & $iB
    EndFunc

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

    Func FPS()
    WinSetTitle("", "", $sGUIText & $iFPS)
    $iFPS = 0
    EndFunc

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

    Func Min($a, $b)
    If $a < $b Then Return $a
    Return $b
    EndFunc

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

    Func _Exit()
    AdlibUnRegister("FPS")
    Local $c
    For $c = 0 To UBound($aBitmaps) - 1
    _GDIPlus_BitmapDispose($aBitmaps[$c][0])
    Next
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_SelectObject($hDC, $DC_obj)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_ReleaseDC($hGUI, $hDC)

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

    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
    EndFunc

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

    Func _WinAPI_CreateDIB($iWidth, $iHeight, $iBitsPerPel = 32) ;taken from WinAPIEx.au3 by Yashied
    Local $tBIHDR, $hBitmap, $pBits
    Local Const $BI_RGB = 0, $DIB_RGB_COLORS = 0
    Local Const $tagBITMAPINFOHEADER = 'dword biSize;long biWidth;long biHeight;ushort biPlanes;ushort biBitCount;dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant'
    $tBIHDR = DllStructCreate($tagBITMAPINFOHEADER)
    DllStructSetData($tBIHDR, 'biSize', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'biWidth', $iWidth)
    DllStructSetData($tBIHDR, 'biHeight', $iHeight)
    DllStructSetData($tBIHDR, 'biPlanes', 1)
    DllStructSetData($tBIHDR, 'biBitCount', $iBitsPerPel)
    DllStructSetData($tBIHDR, 'biCompression', $BI_RGB)
    $hBitmap = _WinAPI_CreateDIBSection(0, $tBIHDR, $DIB_RGB_COLORS, $pBits)
    If @error Then Return SetError(1, 0, 0)
    Return $hBitmap
    EndFunc ;==>_WinAPI_CreateDIB

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

    Func _WinAPI_CreateDIBSection($hDC, ByRef $tBITMAPINFO, $iUsage, ByRef $pBits, $hSection = 0, $iOffset = 0) ;taken from WinAPIEx.au3 by Yashied
    $pBits = 0
    Local $Ret = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', $hDC, 'ptr', DllStructGetPtr($tBITMAPINFO), 'uint', $iUsage, 'ptr*', 0, 'ptr', $hSection, 'dword', $iOffset)
    If @error Or (Not $Ret[0]) Then Return SetError(1, 0, 0)
    $pBits = $Ret[4]
    Return $Ret[0]
    EndFunc ;==>_WinAPI_CreateDIBSection

    [/autoit]

    Warum hast du dein GDI+ Beispiel in Off-Topic gepostet?

    Gruß,
    UEZ

  • Autoit zu C++ konverter

    • UEZ
    • 1. August 2012 um 00:00

    Ich finde den Ansatz von Ward sehr interessant, C Code Inline zu benutzen, um die von Andy dargestellten Geschwindigkeitsprobleme zu lösen.

    D.h. z.B. ich muss eine Bitmap mit Pixeln füllen, tue dies aber mit Inline C oder von mir auch mit C++. Im Prinzip was Andy / Ward mit dem Inline ASM gebastelt hat.

    Zurück zu moritz1243: was ist der Sinn mit AutoIt C++ Code zu erstellen? (nicht negativ gemeint!)

    Gruß,
    UEZ

  • GDI Plus Array

    • UEZ
    • 31. Juli 2012 um 13:53

    Du willst aus vorgefertigten Texten (Menu) aussuchen können und diese dann im Bild positionieren?

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <gdiplus.au3>
    #include <misc.au3>

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

    Global $afont[8]
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg)"))
    If Not $hImage Then Exit _GDIPlus_Shutdown()
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    $hCtxt_bg = _GDIPlus_ImageGetGraphicsContext($hImage)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt_bg, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt_bg, "int", 4)

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

    $x = 140
    $y = 110

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

    $Form1 = GUICreate("Form1", $iW, $iH)
    $MenuItem1 = GUICtrlCreateMenu("Texte und Schriften")
    $mnText1 = GUICtrlCreateMenuItem("Hunde", $MenuItem1)
    $mnText2 = GUICtrlCreateMenuItem("Katzen", $MenuItem1)
    GUISetState()

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

    Global $Text[4]

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

    $Text[0] = "Welpen"
    $Text[1] = "Hunde"
    $Text[2] = "Katzen"
    $Text[3] = "Vögel"

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

    ;_ArrayDisplay($Text)

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

    Global $aFont, $hBrush, $hFamily, $hFont, $hFormat, $tLayout, $aInfo
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    ;$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Global $hDLL = DllOpen("user32.dll")

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Ilse.jpg")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hCtxt_bg)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_Shutdown()
    DllClose($hDLL)
    GUIDelete()
    Exit

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

    Case $mnText1
    $sText = $Text[1]
    _Schrift()
    Case $mnText2
    $sText = $Text[2]
    _Schrift()
    EndSwitch
    If _IsPressed("25") Then
    $x -= 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("27") Then
    $x += 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("26") Then
    $y -= 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    ElseIf _IsPressed("28") Then
    $y += 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    ElseIf _IsPressed("0D") Then
    While _IsPressed("0D")
    WEnd
    _GDIPlus_GraphicsDrawStringEx($hCtxt_bg, $sText, $hFont, $tLayout, $hFormat, $hBrush)
    ConsoleWrite("Text auf das Hintergrundbild kopiert!" & @LF)
    EndIf
    WEnd

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

    Func Update()
    ;MsgBox(0,"",$x&"-"&$y)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush)
    ;_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text2, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return 1
    EndFunc ;==>Update

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

    Func _Schrift()
    $tLayout = 0
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    $afont = _ChooseFont()
    If @error Then Return
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($afont[2])
    $hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
    $tLayout = _GDIPlus_RectFCreate($x, $y, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hCtxt, $sText, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    EndFunc ;==>_Schrift

    [/autoit]


    So was?

    Gruß,
    UEZ

  • GDI Plus Array

    • UEZ
    • 31. Juli 2012 um 13:16

    Du musst die Schrift auch auf das Hintergrundbild übertragen:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <gdiplus.au3>
    #include <misc.au3>

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

    Global $afont[8]
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg)"))
    If Not $hImage Then Exit _GDIPlus_Shutdown()
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    $hCtxt_bg = _GDIPlus_ImageGetGraphicsContext($hImage)

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

    $x = 140
    $y = 110

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

    $Form1 = GUICreate("Form1", $iW, $iH)
    $MenuItem1 = GUICtrlCreateMenu("Texte und Schriften")
    $mnText1 = GUICtrlCreateMenuItem("Hunde", $MenuItem1)
    $mnText2 = GUICtrlCreateMenuItem("Katzen", $MenuItem1)
    GUISetState()

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

    Global $Text[4]

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

    $Text[0] = "Welpen"
    $Text[1] = "Hunde"
    $Text[2] = "Katzen"
    $Text[3] = "Vögel"

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

    ;_ArrayDisplay($Text)

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    ;$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    ;$aFont = _ChooseFont()
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($afont[2])
    $hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
    $tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Global $hDLL = DllOpen("user32.dll")

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Ilse.jpg")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hCtxt_bg)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_Shutdown()
    DllClose($hDLL)
    GUIDelete()
    Exit

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

    Case $mnText1
    _Schrift1()
    Case $mnText2
    _Schrift2()

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

    EndSwitch
    If _IsPressed("25") Then
    $x -= 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("27") Then
    $x += 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("26") Then
    $y -= 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    ElseIf _IsPressed("28") Then
    $y += 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    ElseIf _IsPressed("0D") Then
    _GDIPlus_GraphicsDrawStringEx($hCtxt_bg, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
    EndIf
    WEnd

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

    Func Update()
    ;MsgBox(0,"",$x&"-"&$y)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
    ;_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text2, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return 1
    EndFunc ;==>Update

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

    Func _Schrift1()
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    $afont = _ChooseFont()
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($afont[2])
    $hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
    $tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Global $hDLL = DllOpen("user32.dll")
    EndFunc ;==>_Schrift1

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

    Func _Schrift2()

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    $afont = _ChooseFont()
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($afont[2])
    $hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
    $tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[2], $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Global $hDLL = DllOpen("user32.dll")
    EndFunc ;==>_Schrift2

    [/autoit]

    Wenn du die Enter Taste drückst, wird der Text auf das Hintergrundbild kopiert.

    Gruß,
    UEZ

  • Daten aus CSV Datei in ein Array Übernehmen

    • UEZ
    • 31. Juli 2012 um 12:38

    autoBert: stimmt, denn die Funktion trennt strikt nach Komma und ein Token "Victoria,Dr" wird auch getrennt. Wenn ich den Delimiter ersetze, damit die Trennung eindeutig ist, funzt die Funktion.

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    $gs_dummydata = _
    '"Nachname"|"Vorname"|"Straße"|"Hausnummer"|"PLZ"|"Ort"|"Anzahl"|"Verbrauch"|"Musterartikel"|"Musterart"' & @CRLF & _
    '"Musterman"|"Fritz"|"Feierstr."|5"|"23333"|""Hamelhausen""|"5"|"3050"|""1"|"3"' & @CRLF & _
    '"Musterfrau"|"Victoria,Dr."|"Abendrotstr.""|"7"|"23455"|""Aschendorf""|"3"|""|""1"|"3"' & @CRLF & _
    '"Müller"|"Heinz,Dr."|"Feldstr.""|"1"|"23455"|""Aschendorf""|""|"7700"|""1"|"3"'

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

    Global $aS = StringSplitW($gs_dummydata, "|")
    _ArrayDisplay($aS)

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

    ; #FUNCTION# ======================================================================================
    ; Name ................: StringSplitW()
    ; Version .............: v0.90 build 2012-05-30 beta
    ; Description .......: Splits a string into columns instead of rows as it is done by SplitString(), like a csv file to a 2d array ;)
    ; Syntax ..............: StringSplitW($string, $delimiter, $max_width)
    ; Parameters ........: $string - string to split
    ; $delimiter - the delimter how to split the string
    ; Return values ....: Success - 2d array
    ; Failure 1 - either $string or $delimter is not set
    ; Failure 2 - array width exceeded
    ; Failure 3 - 2D array memory exceeded -> width + height > 0x5EFA
    ; Author ..............: UEZ
    ; Modified ............:
    ; Remarks ............:
    ; Related ..............: StringSplit()
    ; =================================================================================================
    Func StringSplitW($string, $delimiter)
    If $string = "" Or $delimiter = "" Then Return SetError(1, 0, 0)
    Local $chk, $width, $i, $j, $k, $len, $max = 1, $max_width
    Local $aPos[1], $l = 0
    Local $aSplit = StringSplit($string, @LF)
    $max_width = 0x5EFA - $aSplit[0]
    If $max_width < 1 Then Return SetError(3, 0, 0)
    Local $aVertical[$aSplit[0]][$max_width]
    For $k = 1 To $aSplit[0]
    $len = StringLen($aSplit[$k])
    If $len > 1 Then
    $chk = StringReplace($aSplit[$k], $delimiter, $delimiter)
    $width = @extended
    If $width > $max_width Then Return SetError(2, 0, 0)
    If $width >= $max Then $max = $width + 1
    Switch $width
    Case 0
    $aVertical[$l][0] = $aSplit[$k]
    Case Else
    Dim $aPos[$width * 2 + 2]
    $j = 1
    $aPos[0] = 1
    For $i = 0 To $width - 1
    $aPos[$j] = StringInStr($aSplit[$k], $delimiter, 0, $i + 1) - 1
    $aPos[$j + 1] = $aPos[$j] + 2
    $j += 2
    Next
    $aPos[UBound($aPos) - 1] = StringLen($aSplit[$k])
    $j = 0
    For $i = 0 To UBound($aPos) - 1 Step 2
    $aVertical[$l][$j] = StringMid($aSplit[$k], $aPos[$i], $aPos[$i + 1] - $aPos[$i] + 1)
    $j += 1
    Next
    EndSwitch
    $l += 1
    EndIf
    Next
    ReDim $aVertical[$l][$max]
    Return $aVertical
    EndFunc

    [/autoit]

    Gruß,
    UEZ

  • Daten aus CSV Datei in ein Array Übernehmen

    • UEZ
    • 31. Juli 2012 um 10:02

    Probiere es mal damit -> [ gelöst ] CSV-Datei in ein Array einlesen

    Gruß,
    UEZ

  • Xorianator...

    • UEZ
    • 31. Juli 2012 um 09:59

    Auch von mir ein Happy Birthday und alles Gute.

    Gruß,
    UEZ

  • GDI+ Spielerei: Rolle aus Rechtecken

    • UEZ
    • 29. Juli 2012 um 11:59

    Läuft sauber, kein Ruckeln zu sehen.

    Gruß,
    UEZ

  • Gdi+ Grafik speichern

    • UEZ
    • 25. Juli 2012 um 18:52
    [autoit]


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

    [/autoit]

    Gruß,
    UEZ ;)

  • Gdi+ Grafik speichern

    • UEZ
    • 25. Juli 2012 um 16:56

    Klar, das liegt an der Zeile 28:

    [autoit]


    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)

    [/autoit]

    Hier wird eine leere Bitmap mit der Größe $iW bzw. $iH erstellt und per

    [autoit]


    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

    [/autoit]


    befüllt. Wenn die Größe des Bildes in $hImage ungleich der Größe der Bitmap ($hBitmap) ist, dann tritt genau dies ein.

    Du hast jetzt verschiedene Möglichkeiten dies zu lösen. Die einfachste Möglichkeit ist, die GUI und $hBitmap an die Größe des Bildes ($hImage) anzupassen.

    Probiere dies mal selbst hinzubekommen. :D

    Tipp: du musst "nur" zwei Zeilen modifizieren.

    Gruß,
    UEZ

  • Gdi+ Grafik speichern

    • UEZ
    • 25. Juli 2012 um 16:26

    Probiere es mal damit:

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <gdiplus.au3>
    #include <misc.au3>

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg)"))
    If Not $hImage Then Exit _GDIPlus_Shutdown()

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

    $x = 140
    $y = 110
    $iW = 625
    $iH = 443

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

    $Form1 = GUICreate("Form1", $iW, $iH)
    GUISetState()

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

    $aFont = _ChooseFont()

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

    $Text = "Das ist Text 1" & @LF & _
    "Das ist Text 2" & @LF & _
    "Das ist Text 3"

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($form1)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)

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

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $aFont[7])
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($aFont[2])
    $hFont = _GDIPlus_FontCreate($hFamily, $aFont[3], $aFont[1])
    $tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

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

    Global $hDLL = DllOpen("user32.dll")

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Ilse.jpg")
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_Shutdown()
    DllClose($hDLL)
    GUIDelete()
    Exit
    EndSwitch
    If _IsPressed("25") Then
    $x -= 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("27") Then
    $x += 1
    DllStructSetData($tLayout, "X", $x)
    Update()
    ElseIf _IsPressed("26") Then
    $y -= 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    ElseIf _IsPressed("28") Then
    $y += 1
    DllStructSetData($tLayout, "Y", $y)
    Update()
    EndIf
    WEnd

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

    Func Update()
    _GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
    _GDIPlus_GraphicsDrawStringEx($hCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return 1
    EndFunc

    [/autoit]

    Gruß,
    UEZ

  • Unstrukturieren Text parsen - wie ?

    • UEZ
    • 17. Juli 2012 um 23:18

    Probiere es mal damit:

    Spoiler anzeigen
    [autoit]


    $sPop3 = _
    'Received: by s1.vhs.local ' & @CRLF & _
    ' id <01CD6422.821DCACA@s1.vhs.local>; Tue, 17 Jul 2012 15:46:03 +0200' & @CRLF & _
    'Return-Receipt-To: "it" <[email='it@lala.de'][/email]>' & @CRLF & _
    'Content-class: urn:content-classes:message' & @CRLF & _
    'Subject: Test123' & @CRLF & _
    'MIME-Version: 1.0' & @CRLF & _
    'Content-Type: multipart/alternative;' & @CRLF & _
    ' boundary="----_=_NextPart_001_01CD6422.821DCACA"' & @CRLF & _
    'Date: Tue, 17 Jul 2012 15:46:01 +0200' & @CRLF & _
    'Message-ID: <114753C5767DF54A90285C5A1A10A3A3021A52@s1.vhs.local>' & @CRLF & _
    'Disposition-Notification-To: "it" <[email='it@lala.de'][/email]>' & @CRLF & _
    'X-MimeOLE: Produced By Microsoft Exchange V6.5' & @CRLF & _
    'X-MS-Has-Attach: ' & @CRLF & _
    'X-MS-TNEF-Correlator: ' & @CRLF & _
    'Thread-Topic: Test123' & @CRLF & _
    'thread-index: Ac1kInwC5AN8zIg8RJ6OA9xctXvurg==' & @CRLF & _
    'From: "it" <[email='it@lala.de'][/email]>' & @CRLF & _
    'To: "bubu" <[email='bubu@lala.de'][/email]>'
    $sParse = StringRegExpReplace($sPop3, "(?im)[\s\S]*?Subject:\s*(.*)(?s).*", "$1")
    MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$sParse' & @lf & @lf & 'Return:' & @lf & $sParse) ;### Debug MSGBOX

    [/autoit]

    Gruß,
    UEZ

  • Bilder Listview

    • UEZ
    • 17. Juli 2012 um 22:04

    Schaue hier mal rein: _GUIImageList_AddBitmapEx() v0.80 Build 2011-11-05 beta - fügt ein Bild in den _GUIImageList Control hinzu

    Gruß,
    UEZ

  • Bilder Listview

    • UEZ
    • 17. Juli 2012 um 18:03

    Probiere es mal damit:

    Spoiler anzeigen
    [autoit]


    ;Original code by Jayson -> http://www.autoitscript.com/forum/topic/12…ls/#entry888097
    ;Modified by UEZ 2012
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Include <File.au3>
    #Include <EditConstants.au3>
    #Include <Constants.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #include <GDIPlus.au3>

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

    Opt('MustDeclareVars', 1)

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

    Global $sExtFilter = "bmp|gif|jpeg|jpg|png|tif|tiff"
    Global $hGui, $hGui_Preview, $hGui_PreviewSize, $idPic, $idLabel_Info, $Path, $BRowse, $LV, $Pic, $hLV, $aCtrl, $show, $FSF, $timer, $file_prev, $off = False
    Global $hImageList, $sCur, $sLast, $iDX, $iPicState = 0, $DoubleClick = -1
    _GDIPlus_Startup()
    $hGui = GUICreate("Image Viewer", 490, 620)
    $Path = GUICtrlCreateInput("", 10, 10, 400, 20, $ES_READONLY)
    $BRowse = GUICtrlCreateButton("Browse", 420, 10, 60, 20)
    $LV = GUICtrlCreateListView("", 5, 40, 480, 575, -1, BitOr($WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER))
    _GUICtrlListView_SetView($LV, 1)
    _GUICtrlListView_SetIconSpacing($LV, 75, 60)
    $hLV = GUICtrlGetHandle($LV)
    $Pic = GUICtrlCreatePic("", 200, 80, 440, 440)
    GUISetState(@SW_SHOW, $hGui)
    $hGui_PreviewSize = 300
    $hGui_Preview = GUICreate("", $hGui_PreviewSize, $hGui_PreviewSize + 58, -1, -1, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST, $hGui)
    $idPic = GUICtrlCreatePic("", 0, 0, $hGui_PreviewSize, $hGui_PreviewSize)
    $idLabel_Info = GUICtrlCreateLabel("" , 0, $hGui_PreviewSize + 8, $hGui_PreviewSize * 2, 50)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial", 5)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x222222)
    GUISetState(@SW_HIDE, $hGui_Preview)

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

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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

    $show = False
    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    _GDIPlus_Shutdown()
    Exit
    Case $Browse
    If _Browse() Then $show = True
    EndSwitch
    If $show Then StartPreview()
    If Not WinActive($hGui) Then WinActivate($hGui)
    WEnd

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

    Func StartPreview()
    Local $hBmp_Tmp, $file, $iIndex
    $iIndex = _GUICtrlListView_GetSelectedIndices($hLV)
    $file = $FSF & _GUICtrlListView_GetItemText($hLV, $iIndex)
    Local $aPos = _GUICtrlListView_GetItemPosition($hLV, $iIndex)
    If TimerDiff($timer) < 5000 Then
    If $file_prev <> $file Then
    $hBmp_Tmp = _GetImage($file, $hGui_PreviewSize)
    _hBmpToPicControl($idPic, $hBmp_Tmp, 1)
    WinMove($hGui_Preview, "", $aPos[0] + $hGui_PreviewSize / 5, Min(@DesktopHeight - ($hGui_PreviewSize + 130), $aPos[1]), $hGui_PreviewSize, $hGui_PreviewSize + 58, 1)
    GUISetState(@SW_SHOW, $hGui_Preview)
    $file_prev = $file
    $off = False
    EndIf
    Else
    If Not $off Then
    GUISetState(@SW_HIDE, $hGui_Preview)
    $off = True
    EndIf
    EndIf
    EndFunc

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

    Func Min($a, $b)
    If $a < $b Then Return $a
    Return $b
    EndFunc

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

    Func _Browse()
    Local $FL2A, $hBmp, $iCnt = 0
    $FSF = FileSelectFolder("Browse for folder containing pictures", "", "", $hGui)
    If Not @error And FileExists($FSF) Then
    If StringRight($FSF, 1) <> "\" Then $FSF &= "\"
    $FL2A = _FileListToArray($FSF, "*", 1)
    If Not @Error Then
    If IsPtr($hImageList) Then
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))
    _GUiImageList_Destroy($hImageList)
    $hImageList = ""
    _hBmpToPicControl($Pic, $hBmp)
    GUICtrlSetImage($Pic, "")
    $iDX = -1
    $iPicState = 0
    $sCur = ""
    $sLast = ""
    EndIf
    $hImageList = _GUiImageList_Create(60, 60, 5, 3)
    _GUICtrlListView_SetImageList($LV, $hImageList, 0)
    For $i = 1 To $FL2A[0]
    If StringRegExp($FL2A[$i], "(?i)\.(" & $sExtFilter & ")", 0) Then
    $hBmp = _GetImage($FSF & $FL2A[$i], 60)
    _GUiImageList_Add($hImageList, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    _GUICtrlListView_AddItem($LV, $FL2A[$i], $iCnt)
    _GUICtrlListView_SetItemImage($LV, $iCnt, $iCnt)
    $iCnt += 1
    EndIf
    Next
    GUICtrlSetData($Path, $FSF)
    EndIf
    WinSetTitle($hGui, "", "Images Found: " & $iCnt)
    Return True
    Else
    If $FSF = "" Then $show = False
    Return SetError(1, 0, False)
    EndIf
    EndFunc

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

    Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF)
    Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2, $aFTS
    $aFTS = FileGetTime($sFile)
    If @error Then Return SetError(1, 0, 0)
    $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32)
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _WinAPI_DeleteObject($hBmp1)
    _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr))
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    GUICtrlSetData($idLabel_Info, $sFile & @LF & Round(FileGetSize($sFile) / 1024, 0) & " kb (" & $iW & " x " & $iH & ")" & @LF & $aFTS[0] & "/" & $aFTS[1] & "/" & $aFTS[2] & " " & $aFTS[3] & ":" & $aFTS[4] & ":" &$aFTS[5])
    $aGS = _GetScale($iW, $iH, $iWH)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3])
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic)
    $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hBmp2
    EndFunc

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

    Func _GetScale($iW, $iH, $iWH)
    Local $aRet[4]
    If $iW <= $iWH And $iH <= $iWH Then
    $aRet[2] = $iW
    $aRet[3] = $iH
    $aRet[0] = ($iWH - $aRet[2])/2
    $aRet[1] = ($iWH - $aRet[3])/2
    ElseIf $iW > $iH Then
    $aRet[2] = $iWH
    $aRet[3] = $iH/($iW/$iWH)
    $aRet[0] = 0
    $aRet[1] = ($iWH - $aRet[3])/2
    ElseIf $iW < $iH Then
    $aRet[2] = $iW/($iH/$iWH)
    $aRet[3] = $iWH
    $aRet[0] = ($iWH - $aRet[2])/2
    $aRet[1] = 0
    ElseIf $iW = $iH Then
    $aRet[2] = $iWH
    $aRet[3] = $iWH
    $aRet[0] = 0
    $aRet[1] = 0
    EndIf
    Return $aRet
    EndFunc

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

    Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local $hOldBmp
    $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp)
    If $iFlag Then _WinAPI_DeleteObject($hBmp)
    EndFunc

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

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $tInfo2, $aIDX
    $hWndListView = GUICtrlGetHandle($LV)
    $tNMHDR = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code', $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    $tInfo = DllStructCreate('hwnd hWndFrom;int_ptr IDFrom;int Code;int_ptr VKey;int Flags', $ilParam)
    $tInfo2 = DllStructCreate($tagNMLISTVIEW, $ilParam)
    Switch $hWndFrom
    Case $hWndListView
    Switch $iCode
    Case $NM_CLICK
    $iDX = _GUICtrlListView_GetNextItem($hWndListView)
    $timer = TimerInit()
    Case $NM_DBLCLK
    $DoubleClick = _GUICtrlListView_GetNextItem($hWndListView)
    $timer = TimerInit()
    Case $LVN_KEYDOWN
    Switch BitAnd(DllStructGetData($tInfo, "VKey"), 0xFFFF)
    Case $VK_UP
    $iDX = _GUICtrlListView_GetNextItem($hWndListView) -1
    If $iDX < 0 Then $iDX = 0
    Case $VK_DOWN
    $iDX = _GUICtrlListView_GetNextItem($hWndListView) + 1
    If $iDX >= _GUICtrlListView_GetItemCount($hWndListView) Then $iDX -= 1
    EndSwitch
    $timer = TimerInit()
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]

    Gruß,
    UEZ

  • Gdiplus und Icons

    • UEZ
    • 14. Juli 2012 um 10:22

    Hi eukalyptus,

    bei deiner 2. Methode geht leider die Transparenz flöten (zumindest bei mir unter Win7 x64 + Aero). ;)

    Wenn du die 2 _GDIPlus_GraphicsClear() auskommentierst, kannst du sehen, dass die Icons nicht richtig transparent sind.

    In _GUICtrlMenu_CreateBitmap() v0.60 Build 2012-01-07 beta - Erstellt Icons für GUI Menüs ist auch noch eine Variante, aber dein Code aus IconDock fand ich hier passender.

    Gruß,
    UEZ

  • Gdiplus und Icons

    • UEZ
    • 13. Juli 2012 um 21:56

    Hier ein Beispiel:

    Spoiler anzeigen
    [autoit]


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

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

    _GDIPlus_Startup()

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

    $sFile = "Shell32.dll"
    $iIndex = 4;Random(0, 200, 1)
    $iSizeW = 32
    $iSizeH = 32
    $aRet = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sFile, 'int', $iIndex, 'int', $iSizeW, 'int', $iSizeH, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
    $hIcon = $aRet[5]
    $hBitmap = __IconDock_IconToGdiPlus($hIcon, $iSizeW, $iSizeH)
    _WinAPI_DestroyIcon($hIcon)

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

    $iW = _GDIPlus_ImageGetWidth($hBitmap)
    $iH = _GDIPlus_ImageGetHeight($hBitmap)
    $hGUI = GUICreate("", $iW * 2, $iH * 2, -1, -1, $WS_POPUPWINDOW)
    GUISetState()

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

    $hGFX = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGFX, $hBitmap, $iW / 2, $iH / 2)

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

    Do
    Until GUIGetMsg()= -3

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

    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGFX)
    _GDIPlus_Shutdown()
    GUIDelete()

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

    Exit

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

    ; #FUNCTION# ======================================================================================
    ; Name ..........: __IconDock__IconDock_IconToGdiPlus()
    ; Description ...: Internal Function
    ; Author ........: Eukalyptus
    ; =================================================================================================
    Func __IconDock_IconToGdiPlus($hIcon, $iWidth, $iHeight)

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

    Local $tBITMAPINFO = DllStructCreate("dword Size;long Width;long Height;word Planes;word BitCount;dword Compression;dword SizeImage;long XPelsPerMeter;long YPelsPerMeter;dword ClrUsed;dword ClrImportant;dword RGBQuad")
    DllStructSetData($tBITMAPINFO, 'Size', DllStructGetSize($tBITMAPINFO) - 4)
    DllStructSetData($tBITMAPINFO, 'Width', $iWidth)
    DllStructSetData($tBITMAPINFO, 'Height', -$iHeight)
    DllStructSetData($tBITMAPINFO, 'Planes', 1)
    DllStructSetData($tBITMAPINFO, 'BitCount', 32)
    DllStructSetData($tBITMAPINFO, 'Compression', 0)
    DllStructSetData($tBITMAPINFO, 'SizeImage', 0)

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

    Local $hDC = _WinAPI_CreateCompatibleDC(0)
    Local $aRet = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBITMAPINFO), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    Local $pBits = $aRet[4]
    Local $hBmp = $aRet[0]
    Local $hOrig = _WinAPI_SelectObject($hDC, $hBmp)
    _WinAPI_DrawIconEx($hDC, 0, 0, $hIcon, $iWidth, $iHeight)

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

    Local $bAlpha = False
    Local $tData = DllStructCreate("dword[" & $iWidth * $iHeight & "]", $pBits)
    For $i = 1 To $iWidth * $iHeight
    If BitAND(DllStructGetData($tData, 1, $i), 0xFF000000) Then
    $bAlpha = True
    ExitLoop
    EndIf
    Next
    Switch $bAlpha
    Case True
    $aRet = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iWidth * 4, "int", 0x26200A, "ptr", $pBits, "int*", 0)
    Local $hBitmapTemp = $aRet[6]

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

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    _GDIPlus_GraphicsDrawImage($hContext, $hBitmapTemp, 0, 0)

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

    _GDIPlus_BitmapDispose($hBitmapTemp)
    _WinAPI_DeleteObject($hBmp)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDispose($hGraphics)

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

    _WinAPI_SelectObject($hDC, $hOrig)
    _WinAPI_DeleteDC($hDC)
    Case Else
    $aRet = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromHICON", "hwnd", $hIcon, "int*", 0)
    Local $hBitmap = $aRet[2]
    _WinAPI_SelectObject($hDC, $hOrig)
    _WinAPI_DeleteObject($hBmp)
    _WinAPI_DeleteDC($hDC)
    EndSwitch
    Return $hBitmap
    EndFunc ;==>__IconDock_IconToGdiPlus

    [/autoit]

    Gruß,
    UEZ

  • Happy Birthday TheShadowAE

    • UEZ
    • 13. Juli 2012 um 21:54

    Herzlichen Glückwunsch zum Geburtstag und alles Gute!


    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™