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

  • GetUniqueColors

    • UEZ
    • 25. November 2017 um 20:15
    Zitat von AspirinJunkie

    Warum nicht?

    Nun ja, bei einem 35 mp Bild kann ich mir zwar vorstellen, dass ich vielleicht 50% herausholen kann, aber das ist in dieser Zeit Region nicht so relevant. zumal 35 mp Bilder eher die Ausnahmen sind. Kleinere Bilder z.B. in HD Auflösung dauern ca. 150ms und da lohnt sich vermutlich kein MT.

  • GetUniqueColors

    • UEZ
    • 24. November 2017 um 20:18

    AspirinJunkie : diesmal funktionieren die DLLs:

    x64:

    Code
    Dimension: 7360x4912
    Single-Thread-Version:
              Zeitbedarf:  5196.39 ms
           Anzahl Farben:   402990
    
    Multi-Thread-Version:
              Zeitbedarf:   865.69 ms
           Anzahl Farben:   402990

    Hier meine x86 FreeBasic ST Version:

    Code
    Loading image
    Image dimensions: 7360x4912
    Counting all 24-bit colors
    Unique color count: 402990
    1318.890535639614 ms

    Ich glaube nicht, dass MT hier noch was bringt bzw. MT sich richtig lohnt.

    FB Version siehe unten.

    Dateien

    FB - _GDIPlus_ImageCountColors.zip 18,02 kB – 252 Downloads
  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 22:41

    Ist bereits installiert.

  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 22:19

    AspirinJunkie Bei mir funzt dein Skript nicht.

    Code
    CountColors.au3" (28) : ==> Subscript used on non-accessible variable.:
    Return $a_Ret[0]
    Return $a_Ret^ ERROR
  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 15:46

    Oscar : stimmt, wo du es jetzt sagst, hatte ich auch schon recherchiert und festgestellt, dass es am JPEG Decoder hing. Hab's wieder vergessen (Altersamnesie). ;)

  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 13:38

    Das Array unter 32-bit funzt nicht, aber als 64-bit. Da werden schlappe 4 GB einfach belegt. Nicht gut, aber wie soll's auch anders sein!

    Die langsamere Variante unterstützt auch 32-bit Bilder und verbraucht nur einen Bruchteil an Speicher.

  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 11:46

    Leider kann FB nicht 256^4 als Array adressieren oder ich weiß nicht, wie das gehen soll. Jedenfalls mit 256^3, sprich 24-Bit Support, liege ich jetzt bei ca. 150 ms für das HD Amsel Bild.

  • GetUniqueColors

    • UEZ
    • 23. November 2017 um 09:15

    Ich hatte auch vor einiger Zeit diese Funktion in AutoIt und FreeBasic geschrieben und dabei bemerkt, dass die Anzahl der Farben sich von Programm zu Programm unterscheidet.

    Dein Amsel Bild:

    Unsere GDI+ Versionen: 160514

    IfranView: 148516

    XnView: 160537

    Keine Ahnung, wie man nun weiß, welcher Wert der richtige ist.

    Ach ja, meine FB Version benötigt für das HD Amsel Bild ca. 400ms, wobei ich den Weg über Arrays genommen hatte (hinzufügen, sortieren und zählen).

  • GDI+ Problem mit Kollision für bestimmten Bereich (Collision)

    • UEZ
    • 17. November 2017 um 18:24

    Deine 4 Punkte bleiben außerhalb des roten Rechteckes, somit kann deine Figur durchlaufen. Du musst zwei weitere Punkte prüfen, ob sie das rote Rechteck berühren.

    Beispiel Code im engl. Forum.

    Abgesehen davon würde ich nicht _GDIPlus_PathIsVisiblePoint für solche simple Objekte (Rechtecke) benutzen. Da ist eher der Check, wie es Mars gepostet hat, schneller. Aber hier musst du noch zwei weitere Punkte hinzufügen, da ansonsten die Eckpunkte außerhalb liegen.

  • File to Base64 String Code Generator v1.20 Build 2020-06-05

    • UEZ
    • 17. November 2017 um 08:08

    Nee, diese zwei Funktionen sind nicht in der WinAPI Lib enthalten. Keine Ahnung, ob die neuen Modifikationen, Bugfixes, neue Funktionen jemals veröffentlicht werden, da Jon scheinbar kein Interesse mehr an AutoIt hat.

  • File to Base64 String Code Generator v1.20 Build 2020-06-05

    • UEZ
    • 17. November 2017 um 04:01
    Zitat von Tweaky

    Wie sieht es hiermit aus?

    - Gibt es auch Ersatzfunktionen für "_WinAPI_LZNTDecompress" bzw. "_Base64Decode"?

    Warum?

  • File to Base64 String Code Generator v1.20 Build 2020-06-05

    • UEZ
    • 16. November 2017 um 17:22

    Ich würde das so machen:

    AutoIt
    ...
    _GDIPlus_Startup()
    Global $msg
    Global Const $hGUI = GUICreate("Example", 600, 400)
    Global Const $idLogo = GUICtrlCreatePic("", 215, 20, 169, 68)
    Global Const $idLogo2 = GUICtrlCreatePic("", 215, 150, 169, 68)
    
    ;original
    Global Const $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(Merlin(), True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Logo))
    
    
    ;Größe verändert >>> so OK?
    Global $Bmp_Logo1 = _GDIPlus_BitmapCreateFromMemory(Merlin()) ;wenn 2. Parameter = True, dann GDI Bild, ansonsten GDIPlus Bild
    Global $iWidth = _GDIPlus_ImageGetWidth($Bmp_Logo1)
    Global $iHeight = _GDIPlus_ImageGetHeight($Bmp_Logo1)
    Global $hBitmap_Resized = _GDIPlus_ImageResize($Bmp_Logo1, 150, 150 * $iHeight / $iWidth) ;resize image
    Global $Bmp_Logo2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Resized) ;convert GDI+ bitmap to GDI bitmap
    _WinAPI_DeleteObject(GUICtrlSendMsg($idLogo2, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Logo2))
    
    _GDIPlus_BitmapDispose($Bmp_Logo1)
    _GDIPlus_BitmapDispose($hBitmap_Resized)
    _WinAPI_DeleteObject($Bmp_Logo)
    _WinAPI_DeleteObject($Bmp_Logo2)
    
    GUISetState()
    
    
    While True
        $msg = GUIGetMsg()
        Switch $msg
            Case $idLogo
                MsgBox(0, "Information", "The picture has been clicked!")
            Case $GUI_EVENT_CLOSE
                _GDIPlus_Shutdown()
                GUIDelete($hGUI)
                Exit
        EndSwitch
    WEnd
    ...
    Alles anzeigen
  • File to Base64 String Code Generator v1.20 Build 2020-06-05

    • UEZ
    • 16. November 2017 um 15:20
    Zitat von Tweaky

    UEZ

    fände es genial, wenn du in die Funktion "Load_BMP_From_Mem" noch eine Option zum ändern der Bildgröße (Breite / Höhe) einbauen könntest.

    Super Tool;)

    Also, "Load_BMP_From_Mem" heißt jetzt "_GDIPlus_BitmapCreateFromMemory" (Raider heißt jetzt Twix, sonst ändert sich nix). :)

    Um die Bildgröße zu ändern, kannst du _GDIPlus_ImageScale oder _GDIPlus_ImageResize benutzen. ;)

  • GetUniqueColors

    • UEZ
    • 15. November 2017 um 22:20

    Nun ja, es sollten auch 32-bit Bilder unterstützt werden, was die schnellste Variante in dieser Version nicht tut.

    Als Beispiel ein Bild mit genau 256 Farben, die nur sich über den Alpha Kanal unterscheiden.

    AutoIt
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Version=b
    #include <Array.au3>
    #include <GDIPlus.au3>
    
    
    _GDIPlus_Startup()
    Global Const $iW = 256, $iH = 1
    Global $hImage = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Global $iX, $iY
    Global $fTimer = TimerInit()
    For $iY = 0 To $iH - 1
        For $iX = 0 To $iW - 1
            _GDIPlus_BitmapSetPixel($hImage, $iX, $iY, BitShift($iX, -24) + 0xFFFF00)
        Next
    Next
    ConsoleWrite("Test image created in " & Round(TimerDiff($fTimer), 2) & " ms" & @CRLF)
    ;~ Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test.png")
    _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Test.png")
    
    $fTimer = TimerInit()
    ;~ Global $iColorCount = _GetUniqueColors($hImage)
    Global $iColorCount = _GDIPlus_ImageGetColorCount5($hImage)
    Global $fEndTime = Round(TimerDiff($fTimer), 2)
    MsgBox(0, "Color Counter", "Found " & $iColorCount & " unique colors in " & $fEndTime & " ms.")
    ConsoleWrite("Found " & $iColorCount & " unique colors" & @CRLF)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    
    Func _GetUniqueColors(ByRef $hImage)
        Local $aColor[0xFFFFFF + 1], $iColorCounter = 0
        Local $iW, $iH, $tBitmapData, $pScan0, $tPixel, $iOffset, $iColor
        $iW = _GDIPlus_ImageGetWidth($hImage)
        $iH = _GDIPlus_ImageGetHeight($hImage)
        $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
        $pScan0 = DllStructGetData($tBitmapData, 'Scan0')
        $tPixel = DllStructCreate('uint[' & $iW * $iH & '];', $pScan0)
        ConsoleWrite('$iW * $iH = ' & $iW * $iH & ' px' & @CRLF)
        For $iY = 0 To $iH - 1
            $iOffset = $iY * $iW + 1
            For $iX = 0 To $iW - 1
                $iColor = DllStructGetData($tPixel, 1, $iOffset + $iX) - 0xFF000000
                $aColor[$iColor] += 1
                If $aColor[$iColor] = 1 Then $iColorCounter += 1
            Next
        Next
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        $tPixel = 0
        Return $iColorCounter
    EndFunc
    
    Func _GDIPlus_ImageGetColorCount5($hImage) ;
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32RGB)
        Local $iScan0 = DllStructGetData($tBitmapData, "Scan0")
        Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];", $iScan0)
        Local $iColorCount = 0, $aColors[0xFFFFFFFF]
        If @error Then Return SetError(1, 0, -1) ;internal error
        Local $iX, $iY, $iPos
        For $iY = 0 To $iH - 1
            $iRowOffset = $iY * $iW + 1
            For $iX = 0 To $iW - 1
                $iPos = DllStructGetData($tPixel, 1, $iRowOffset + $iX)
                If Not $aColors[$iPos] Then
                    $aColors[$iPos] = 1
                    $iColorCount += 1
                EndIf
            Next
        Next
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Return $iColorCount
    EndFunc   ;==>_GDIPlus_ImageGetColorCount5
    
    Func _GDIPlus_ImageGetColorCount1($hImage) ;fastest but uses a lot of memory for huge images!
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        If $iW * $iH > 2 ^ 24 Then Return SetError(1, 0, -1) ;will cause memory issues
        Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
        Local Const $iScan0 = $tBitmapData.Scan0
        Local $tPixel = DllStructCreate("byte Binary[" & $iW * $iH * 4 & "];", $iScan0)
        Local $bData = $tPixel.Binary
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Local $aResult = StringRegExp($bData, "[[:xdigit:]]{8}", 3), $y, $s, $iColorCount = 0
        If $iW * $iH <> UBound($aResult) Then Return SetError(1, 0, -2) ;internal error
        For $y = 0 To UBound($aResult) - 1
            $s = "_" & $aResult[$y] & "_"
            If Not IsDeclared($s) Then
                Assign($s, 0, 1)
                $iColorCount += 1
            EndIf
        Next
        $bData = Null
        $tPixel = Null
        $aResult = Null
        Return $iColorCount
    EndFunc   ;==>_GDIPlus_ImageGetColorCount1
    
    Func _GDIPlus_ImageGetColorCount2($hImage) ;fast
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        If $iW * $iH > 2 ^ 24 Then Return SetError(1, 0, -1) ;will cause memory issues
        Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
        Local Const $iScan0 = $tBitmapData.Scan0
        Local $tPixel = DllStructCreate("byte Binary[" & $iW * $iH * 4 & "];", $iScan0)
        Local $bData = $tPixel.Binary
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Local $aResult = StringRegExp($bData, "[[:xdigit:]]{8}", 3), $y, $s, $iColorCount = 0
        If $iW * $iH <> UBound($aResult) Then Return SetError(1, 0, -2) ;internal error
        $f = TimerInit()
        $aResult = _ArrayUnique($aResult)
        $bData = Null
        $tPixel = Null
        Return $aResult[0]
    EndFunc   ;==>_GDIPlus_ImageGetColorCount2
    
    Func _GDIPlus_ImageGetColorCount3($hImage) ;slow
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32RGB)
        Local $iScan0 = DllStructGetData($tBitmapData, "Scan0")
        Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];", $iScan0)
        Local $iColorCount = 0, $aColors[$iW * $iH]
        If @error Then Return SetError(1, 0, -1) ;internal error
        Local $iX, $iY, $iZ = 0
        For $iY = 0 To $iH - 1
            $iRowOffset = $iY * $iW + 1
            For $iX = 0 To $iW - 1
                $aColors[$iZ] = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ;get pixel color
                $iZ += 1
            Next
        Next
        $aColors = _ArrayUnique($aColors, 0, 0, 0, $ARRAYUNIQUE_COUNT, 0)
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Return $aColors[0]
    EndFunc   ;==>_GDIPlus_ImageGetColorCount3
    Alles anzeigen
  • GetUniqueColors

    • UEZ
    • 14. November 2017 um 18:58

    Ich hatte das hier mal zusammengestellt:

    AutoIt
    #AutoIt3Wrapper_UseX64=n
    #AutoIt3Wrapper_Version=b
    #include <Array.au3>
    #include <GDIPlus.au3>
    
    
    Global $sFile = FileOpenDialog("Select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif)")
    If @error Then Exit
    _GDIPlus_Startup()
    Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Global $fTimer = TimerInit()
    Global $iColorCount = _GDIPlus_ImageGetColorCount2($hImage)
    Global $fEndTime = Round(TimerDiff($fTimer), 2)
    MsgBox(0, "Color Counter", "Found " & $iColorCount & " unique colors in " & $fEndTime & " ms.")
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    
    
    Func _GDIPlus_ImageGetColorCount1($hImage) ;fastest but uses a lot of memory for huge images!
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        If $iW * $iH > 2 ^ 24 Then Return SetError(1, 0, -1) ;will cause memory issues
        Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
        Local Const $iScan0 = $tBitmapData.Scan0
        Local $tPixel = DllStructCreate("byte Binary[" & $iW * $iH * 4 & "];", $iScan0)
        Local $bData = $tPixel.Binary
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Local $aResult = StringRegExp($bData, "[[:xdigit:]]{8}", 3), $y, $s, $iColorCount = 0
        If $iW * $iH <> UBound($aResult) Then Return SetError(1, 0, -2) ;internal error
        For $y = 0 To UBound($aResult) - 1
            $s = "_" & $aResult[$y] & "_"
            If Not IsDeclared($s) Then
                Assign($s, 0, 1)
                $iColorCount += 1
            EndIf
        Next
        $bData = Null
        $tPixel = Null
        $aResult = Null
        Return $iColorCount
    EndFunc   ;==>_GDIPlus_ImageGetColorCount1
    
    Func _GDIPlus_ImageGetColorCount2($hImage) ;fast
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        If $iW * $iH > 2 ^ 24 Then Return SetError(1, 0, -1) ;will cause memory issues
        Local Const $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
        Local Const $iScan0 = $tBitmapData.Scan0
        Local $tPixel = DllStructCreate("byte Binary[" & $iW * $iH * 4 & "];", $iScan0)
        Local $bData = $tPixel.Binary
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Local $aResult = StringRegExp($bData, "[[:xdigit:]]{8}", 3), $y, $s, $iColorCount = 0
        If $iW * $iH <> UBound($aResult) Then Return SetError(1, 0, -2) ;internal error
        $f = TimerInit()
        $aResult = _ArrayUnique($aResult)
        $bData = Null
        $tPixel = Null
        Return $aResult[0]
    EndFunc   ;==>_GDIPlus_ImageGetColorCount2
    
    Func _GDIPlus_ImageGetColorCount3($hImage) ;slow
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32RGB)
        Local $iScan0 = DllStructGetData($tBitmapData, "Scan0")
        Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];", $iScan0)
        Local $iColorCount = 0, $aColors[$iW * $iH]
        If @error Then Return SetError(1, 0, -1) ;internal error
        Local $iX, $iY, $iZ = 0
        For $iY = 0 To $iH - 1
            $iRowOffset = $iY * $iW + 1
            For $iX = 0 To $iW - 1
                $aColors[$iZ] = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ;get pixel color
                $iZ += 1
            Next
        Next
        $aColors = _ArrayUnique($aColors, 0, 0, 0, $ARRAYUNIQUE_COUNT, 0)
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        Return $aColors[0]
    EndFunc   ;==>_GDIPlus_ImageGetColorCount3
    
    Func _GDIPlus_ImageGetColorCount4($hImage) ;very slow
        Local Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
        Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32RGB)
        Local $iScan0 = DllStructGetData($tBitmapData, "Scan0")
        Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];", $iScan0)
        Local $iColorCount = 0, $oSD = ObjCreate("Scripting.Dictionary")
        If @error Then Return SetError(1, 0, -1) ;internal error
        Local $iX, $iY
        For $iY = 0 To $iH - 1
            $iRowOffset = $iY * $iW + 1
            For $iX = 0 To $iW - 1
                $iPixel = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ;get pixel color
                If Not $oSD.Exists($iPixel) Then
                    $iColorCount += 1
                    $oSD.Add($iPixel, $iColorCount)
                EndIf
            Next
        Next
        _GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
        $oSD.RemoveAll()
        Return $iColorCount
    EndFunc   ;==>_GDIPlus_ImageGetColorCount4
    Alles anzeigen
  • GDI+ Transparenz Problem bei Bildüberlappung

    • UEZ
    • 27. Oktober 2017 um 23:36

    Hier ein Lösungsansatz:

    AutoIt
    ;coded by UEZ
    
    #include <GDIPlus.au3>
    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    
    _GDIPlus_Startup()
    Global $hGUI, $bExit
    Global Const $iW = @DesktopWidth * 0.95, $iH = @DesktopHeight * 0.90, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Test"
    
    AutoItSetOption("GUIOnEventMode", 1)
    
    GDIPlus_Test()
    
    AutoItSetOption("GUIOnEventMode", 0)
    _GDIPlus_Shutdown()
    
    
    Func GDIPlus_Test()
        $bExit = False
        $hGUI = GUICreate($sTitle, $iW, $iH)
        GUISetState(@SW_SHOW, $hGUI)
    
        Local Const $hDC = _WinAPI_GetDC($hGUI)
        Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
        Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
        Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap)
        Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
        _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
        _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    
        Local $aSprites[3][6], $i, $iDX, $iDY, $iControl, $aInfo, $aCtrlPos
        For $i = 0 To UBound($aSprites) - 1
            $aSprites[$i][0] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\tree0" & $i + 1 & "_01.png")
            $aSprites[$i][1] = _GDIPlus_ImageGetWidth($aSprites[$i][0])
            $aSprites[$i][2] = _GDIPlus_ImageGetHeight($aSprites[$i][0])
            $aSprites[$i][3] = Random(0, $iW - $aSprites[$i][1], 1)
            $aSprites[$i][4] = Random(0, $iH - $aSprites[$i][2], 1)
            $aSprites[$i][5] = GUICtrlCreateLabel("", $aSprites[$i][3], $aSprites[$i][4], $aSprites[$i][1], $aSprites[$i][2])
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            _GDIPlus_GraphicsDrawImageRect($hCanvas, $aSprites[$i][0], $aSprites[$i][3], $aSprites[$i][4], $aSprites[$i][1], $aSprites[$i][2])
        Next
    
        Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFFA0A0A0), _
                    $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0101010)
    
        $iFPS = 0
        GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About")
    
        Do
            DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, "float", $iW, "float", $iH)
            $aInfo = GUIGetCursorInfo($hGUI)
            If $aInfo[2] And $aInfo[4] Then
                $iControl = FindCtrl($aInfo[4], $aSprites)
                If Not @error Then
                    $iDX = Abs(MouseGetPos(0) - $aSprites[$iControl][3])
                    $iDY = Abs(MouseGetPos(1) - $aSprites[$iControl][4])
                    Do
                        DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, "float", $iW, "float", $iH)
                        $aInfo = GUIGetCursorInfo($hGUI)
                        $aCtrlPos = ControlGetPos($hGUI, "", $aSprites[$iControl][5])
                        $aSprites[$iControl][3] = MouseGetPos(0) - $iDX
                        $aSprites[$iControl][4] = MouseGetPos(1) - $iDY
                        For $i = 0 To UBound($aSprites) - 1
                            _GDIPlus_GraphicsDrawImageRect($hCanvas, $aSprites[$i][0], $aSprites[$i][3], $aSprites[$i][4], $aSprites[$i][1], $aSprites[$i][2])
                        Next
                        _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY)
                    Until Not $aInfo[2]
                    ControlMove($hGUI, "", $aSprites[$iControl][5], $aSprites[$iControl][3], $aSprites[$iControl][4])
                EndIf
            Else
                For $i = 0 To UBound($aSprites) - 1
                    _GDIPlus_GraphicsDrawImageRect($hCanvas, $aSprites[$i][0], $aSprites[$i][3], $aSprites[$i][4], $aSprites[$i][1], $aSprites[$i][2])
                Next
            EndIf
    
            _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY)
            If $bExit Then ExitLoop
        Until Not Sleep(10)
    
        For $i = 0 To UBound($aSprites) - 1
            _GDIPlus_ImageDispose($aSprites[$i][0])
        Next
        _GDIPlus_BrushDispose($hBrush_Clr)
        _GDIPlus_BrushDispose($hBrush_FPS)
        _GDIPlus_GraphicsDispose($hCanvas)
        _WinAPI_SelectObject($hDC_backbuffer, $DC_obj)
        _WinAPI_DeleteDC($hDC_backbuffer)
        _WinAPI_DeleteObject($hHBitmap)
        _WinAPI_ReleaseDC($hGUI, $hDC)
        GUIDelete($hGUI)
    EndFunc   ;==>GDIPlus_Test
    
    Func FindCtrl($iCtrl, $aArray)
        Local $i
        For $i = 0 To UBound($aArray) - 1
            If $aArray[$i][5] = $iCtrl Then Return $i
        Next
        Return SetError(0, 0, -1)
    EndFunc
    
    Func _Exit_About()
        $bExit = True
    EndFunc   ;==>_Exit_About
    Alles anzeigen
  • GDIPlus - Bereich immun machen

    • UEZ
    • 8. September 2017 um 21:43

    Du musst die Positionen der Controls ermitteln und sie dann ausclippen.

    Hier ein älteres Beispiel:

    AutoIt
    #AutoIt3Wrapper_UseX64=n
    ;coded by UEZ 2009
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIplus.au3>
    #include <WindowsConstants.au3>
    
    Local Const $width = @DesktopWidth / 2
    Local Const $height = @DesktopHeight / 2
    Opt("GUIOnEventMode", 1)
    
    Local $fps = 0, $fps_diff, $fps_maintimer, $fps_timer, $display_FPS = -15
    Local $trig = ACos(-1)  / 180
    Local $max_dots = 100
    Local $max_speed = 8
    Local $iWidth = 10
    Local $iHeight = 10
    Local $hGUI = GUICreate("Border Collision with " & $max_dots & " objects! 0 FPS", $width, $height, -1, -1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    Local $Button = GUICtrlCreateButton("Exit", $width / 2 - 50, $height / 2 - 15, 100, 30)
    Local $Input = GUICtrlCreateInput("Coded by UEZ", $width / 4, $height - 40, $width / 2, 20, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
    
    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
    Local $hBrush_Clear = _GDIPlus_BrushCreateSolid(0xFF000000)
    
    ;~ Global Const $GW_CHILD = 5
    ;~ Global Const $GW_HWNDNEXT = 2
    Global $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $width, $height)
    Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD)
    Global $aRect
    Do
        $aRect = ControlGetPos($hChild, "", 0)
        _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3)
        $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT)
    Until Not $hChild
    _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion)
    _GDIPlus_RegionDispose($hRegion)
    
    GUISetState()
    
    GUICtrlSetOnEvent($Button, "Close")
    
    
    Dim $coordinates[$max_dots][5], $angle
    Dim $hBrush[$max_dots]
    Initialize()
    
    $fps_maintimer = TimerInit()
    Do
        For $x = -0x7FFFFFFF To 0x7FFFFFFF
            $fps_timer = TimerInit()
            Draw_Dots()
            Calculate_New_Position()
            Sleep(30)
            $fps_diff = TimerDiff($fps_timer)
            If TimerDiff($fps_maintimer) > 999 Then ;calculate FPS
                $fps = Round(1000 / $fps_diff, 2)
                $fps_maintimer = TimerInit()
            EndIf
            WinSetTitle($hGUI, "", "Border Collision with " & $max_dots & " objects! " & $fps & " FPS")
        Next
    Until False
    
    Func Initialize()
        For $k = 0 To $max_dots - 1
            $hBrush[$k] = _GDIPlus_BrushCreateSolid(Random(0xD0808080, 0xD0FFFFFF, 1))
            New_Coordinates($k)
        Next
    EndFunc   ;==>Initialize
    
    Func Draw_Dots()
        Local $i, $temp_x, $temp_y
        _GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $width, $height, $hBrush_Clear)
        For $i = 0 To $max_dots - 1
            _GDIPlus_GraphicsFillEllipse($hBackbuffer, $coordinates[$i][0], $coordinates[$i][1], $iWidth, $iHeight, $hBrush[$i])
        Next
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
    EndFunc   ;==>Draw_Dots
    
    Func New_Coordinates($k)
        $coordinates[$k][0] = $width / 2 ;Random($width / 20, $width - $width / 20, 1);start x position
        $coordinates[$k][1] = $height / 2 ;Random($height / 20, $height - $height / 20, 1) ;start y position
        $coordinates[$k][2] = Random(1, $max_speed, 1) ;speed of pixel
        $angle = Random(0, 359, 1)
    ;~ ConsoleWrite("Angle: " & $angle & "°" & @CRLF)
        $coordinates[$k][3] = $coordinates[$k][2] * Cos($angle * $trig)
        $coordinates[$k][4] = $coordinates[$k][2] * Sin($angle * $trig)
    EndFunc   ;==>New_Coordinates
    
    Func Calculate_New_Position()
        Local $k
        For $k = 0 To $max_dots - 1
            $coordinates[$k][0] += $coordinates[$k][3] ;increase x coordinate with appropriate slope
            $coordinates[$k][1] += $coordinates[$k][4] ;increase y coordinate with appropriate slope
            If $coordinates[$k][0] <= 0 Then ;border collision x left
                $coordinates[$k][0] = 1
                $coordinates[$k][3] *= -1
            ElseIf $coordinates[$k][0] >= $width - $iWidth Then ;border collision x right
                $coordinates[$k][0] = $width - ($iWidth + 1)
                $coordinates[$k][3] *= -1
            EndIf
            If $coordinates[$k][1] <= 0 Then ;border collision y top
                $coordinates[$k][1] = 1
                $coordinates[$k][4] *= -1
            ElseIf $coordinates[$k][1] >= $height - $iHeight Then ;border collision y bottom
                $coordinates[$k][1] = $height - ($iHeight + 1)
                $coordinates[$k][4] *= -1
            EndIf
        Next
    EndFunc   ;==>Calculate_New_Position
    
    Func close()
        For $k = 0 To $max_dots - 1
            _GDIPlus_BrushDispose($hBrush[$k])
        Next
        _GDIPlus_BrushDispose($hBrush_Clear)
        _GDIPlus_GraphicsDispose($hBackbuffer)
        _GDIPlus_BitmapDispose($hBitmap)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_Shutdown()
        Exit
    EndFunc   ;==>close
    Alles anzeigen
  • Genial einfaches Tool zur Web Recherche - Smartclip

    • UEZ
    • 16. August 2017 um 23:59
    Zitat von Tuxedo

    Wenn ich noch 30 Jahre jünger wäre und gut Englisch könnte, würde ich auf C++ oder Delphi umsteigen und es dort verwirklichen.

    In C++ oder Delphi ist der Code ähnlich, nur komplizierter, da du auch die WinAPI Funktionen selber schreiben musst. ;)

    Modus 2 ist im PNG Binär Format und wird nur von wenigen Programmen, wie z.B. Paint.Net, unterstützt.
    Modus 3 wir sogar in Paint.Net transparent angezeigt.

    Apropos Englisch, ohne Englisch kommt man heute leider nicht weit, aber gibt ja Google Translate. ^^

  • String auf spezielles Format untersuchen

    • UEZ
    • 16. August 2017 um 23:38

    Kann man das Ganze nicht mit der Funktion Execute() erschlagen oder zumindest den größten Teil?

    AutoIt
    ConsoleWrite(Execute("1") & @CRLF)
    ConsoleWrite(Execute("2.3") & @CRLF)
    ConsoleWrite(Execute("-0") & @CRLF)
    ConsoleWrite(Execute("-0.12e-1") & @CRLF)
    ConsoleWrite(Execute("22.123912e+3") & @CRLF)
    ConsoleWrite(Execute("0e12") & @CRLF)
    
    
    ConsoleWrite(Execute("-0A") & @CRLF)
    ConsoleWrite(Execute("1e12e20") & @CRLF)
  • Genial einfaches Tool zur Web Recherche - Smartclip

    • UEZ
    • 16. August 2017 um 23:11

    Hast du alle 3 Modi getestet?

    Und wie gesagt unterstützt nicht jede Applikation die Formate DIBv5 und PNG.

    In Excel kann ich z.B. das PNG Format benutzen. XnView unterstützt partiell DIBv5.

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™