Jump to content

show images without using much cpu


Go to solution Solved by UEZ,

Recommended Posts

Estou tentando criar uma animação usando imagens .jpg, mas o consumo de cpu é muito alto, algo em torno de 40% ao mostrar as imagens, alguém sabe como mostrar imagens consumindo menos recursos de cpu, talvez usando alguma dll.

isso é o que eu tenho até agora

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

Global $Form, $Pic_img, $interval, $imgs, $qtde_img, $conta_img = 0

$interval = 1000 / 30; images per second

$Form = GUICreate("Video_jpg", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x000000, $Form)
$Pic_img = GUICtrlCreatePic(_Preto(True), 0, 0, @DesktopWidth, @DesktopHeight)
GUISetState(@SW_SHOW)

HotKeySet("{esc}", "Sair")

conta_imgs()

While 1
    IF $qtde_img > 0 THEN Play()
    Sleep($interval)
WEnd

Func conta_imgs()
    $imgs = _FileListToArray(@ScriptDir & "\test", "*.jpg")
    If Not @error Then
        $qtde_img = $imgs[0]
    Else
        $qtde_img = 0
    EndIf
EndFunc   ;==>conta_imgs

Func Play()
    $conta_img += 1
    If $conta_img = $qtde_img Then $conta_img = 1
    GUICtrlSetImage($Pic_img, @ScriptDir & "\test\" & $conta_img & ".jpg")
EndFunc   ;==>Play

Func Sair()
    GUIDelete($Form)
    Exit
EndFunc   ;==>Sair

Func _Preto($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\Preto.jpg"
    $bData = "7bEA/9j/4AAQSkYASUYAAQEBAGABABAA/9sAQwAIAAYGBwYFCAcHAAcJCQgKDBQNAAwLCwwZEhMPABQdGh8eHRocABwgJC4nICIsACMcHCg3KSwwADE0NDQfJzk9gDgyPC4zNDIBiAABCQkJDAsMGAANDRgyIRwhMgEuAP/AABEIAGIAAHcDASIAAhEAAQMRAf/EAB+wAAABBQCtAbAAAwAAAQIDBAUGBwgICQoLACC1EAACAAEDAwIEAwUFFAQEAC19AB8ABBEABRIhMUEGE1EAYQcicRQygZEAoQgjQrHBFVIA0fAkM2JyggkAChYXGBkaJSYAJygpKjQ1NjcAODk6Q0RFRkcASElKU1RVVlcAWFlaY2RlZmcAaGlqc3R1dncAeHl6g4SFhocAiImKkpOUlZYAl5iZmqKjpKUApqeoqaqys7QAtba3uLm6wsMAxMXGx8jJytIA09TV1tfY2doA4eLj5OXm5+gA6erx8vP09fYQ9/j5+"
    $bData &= "oFrAQADFwNrhmyMaxGAawIEBAgDBAeBawECdwABABARBAUhMQYSAEFRB2FxEyIyAIEIFEKRobHBAAkjM1LwFWJyANEKFiQ04SXxdwFtgmwjbIJyNgY2xzXaEAAMAwEAbwMRAAA/APn+iiigAg//AP8Q/yDSIA//2Q=="
    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __Preto(__PretoB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __Preto(__PretoB64($bData))
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_Preto
Func __PretoB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__PretoB64

Func __Preto($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf
    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))
    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__Preto

Baixe os arquivos de teste:   https://mega.nz/file/0U8BRQbJ#5C0B-38RAtvZZae7h_2dRfBfOtKrTWga2XD_rphV-cM

Edited by Belini
Link to comment
Share on other sites

Link to comment
Share on other sites

Here :

#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <File.au3>

Opt("MustDeclareVars", True)

Example()

Func Example()
  Local $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
  GUISetState(@SW_SHOW)
  Local $aFile = _FileListToArray(".\test", "*.jpg", $FLTA_FILES, True)
  ;_ArrayDisplay($aFile)

  _GDIPlus_Startup()
  Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI), $hImage
  For $i = 1 To $aFile[0]
    $hImage = _GDIPlus_ImageLoadFromFile($aFile[$i])
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _GDIPlus_ImageDispose($hImage)
    Sleep(30)
  Next

  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE

  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_Shutdown()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

@Nine dropped to 20% but the image doesn't take up the whole screen

 

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

_GDIPlus_Startup()

GLOBAL $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetState(@SW_SHOW)

GLOBAL $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI), $hImage
Global $interval, $imgs, $qtde_img, $conta_img = 0

$interval = 1000 / 30; images per second

HotKeySet("{esc}", "Sair")

conta_imgs()

While 1
    IF $qtde_img > 0 THEN Play()
    Sleep($interval)
WEnd

Func conta_imgs()
    $imgs = _FileListToArray(@ScriptDir & "\test", "*.jpg")
    If Not @error Then
        $qtde_img = $imgs[0]
    Else
        $qtde_img = 0
    EndIf
EndFunc   ;==>conta_imgs

Func Play()
    LOCAL $hImage
    $conta_img += 1
    If $conta_img = $qtde_img Then $conta_img = 1
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test\" & $conta_img & ".jpg")
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    _GDIPlus_ImageDispose($hImage)
EndFunc   ;==>Play

Func Sair()
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>Sair

Func _Preto($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\Preto.jpg"
    $bData = "7bEA/9j/4AAQSkYASUYAAQEBAGABABAA/9sAQwAIAAYGBwYFCAcHAAcJCQgKDBQNAAwLCwwZEhMPABQdGh8eHRocABwgJC4nICIsACMcHCg3KSwwADE0NDQfJzk9gDgyPC4zNDIBiAABCQkJDAsMGAANDRgyIRwhMgEuAP/AABEIAGIAAHcDASIAAhEAAQMRAf/EAB+wAAABBQCtAbAAAwAAAQIDBAUGBwgICQoLACC1EAACAAEDAwIEAwUFFAQEAC19AB8ABBEABRIhMUEGE1EAYQcicRQygZEAoQgjQrHBFVIA0fAkM2JyggkAChYXGBkaJSYAJygpKjQ1NjcAODk6Q0RFRkcASElKU1RVVlcAWFlaY2RlZmcAaGlqc3R1dncAeHl6g4SFhocAiImKkpOUlZYAl5iZmqKjpKUApqeoqaqys7QAtba3uLm6wsMAxMXGx8jJytIA09TV1tfY2doA4eLj5OXm5+gA6erx8vP09fYQ9/j5+"
    $bData &= "oFrAQADFwNrhmyMaxGAawIEBAgDBAeBawECdwABABARBAUhMQYSAEFRB2FxEyIyAIEIFEKRobHBAAkjM1LwFWJyANEKFiQ04SXxdwFtgmwjbIJyNgY2xzXaEAAMAwEAbwMRAAA/APn+iiigAg//AP8Q/yDSIA//2Q=="
    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __Preto(__PretoB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __Preto(__PretoB64($bData))
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_Preto
Func __PretoB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__PretoB64

Func __Preto($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf
    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))
    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__Preto

 

Link to comment
Share on other sites

@Nine now it takes up the whole screen but the cpu consumption is back to 40%

@Andreik it would just be an animation for when playing .mp3 music

 

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

_GDIPlus_Startup()

GLOBAL $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetState(@SW_SHOW)

GLOBAL $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI), $hImage
Global $interval, $imgs, $qtde_img, $conta_img = 0

$interval = 1000 / 30; images per second

HotKeySet("{esc}", "Sair")

conta_imgs()

While 1
    IF $qtde_img > 0 THEN Play()
    Sleep($interval)
WEnd

Func conta_imgs()
    $imgs = _FileListToArray(@ScriptDir & "\test", "*.jpg")
    If Not @error Then
        $qtde_img = $imgs[0]
    Else
        $qtde_img = 0
    EndIf
EndFunc   ;==>conta_imgs

Func Play()
    LOCAL $hImage, $hBitmap_Scaled
    $conta_img += 1
    If $conta_img = $qtde_img Then $conta_img = 1
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test\" & $conta_img & ".jpg")
    $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, @DesktopWidth, @DesktopHeight) 
   _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Scaled, 0, 0)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap_Scaled)
EndFunc   ;==>Play

Func Sair()
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>Sair

Func _Preto($lToSave = False, $sPath = @TempDir, $lExecute = False)
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\Preto.jpg"
    $bData = "7bEA/9j/4AAQSkYASUYAAQEBAGABABAA/9sAQwAIAAYGBwYFCAcHAAcJCQgKDBQNAAwLCwwZEhMPABQdGh8eHRocABwgJC4nICIsACMcHCg3KSwwADE0NDQfJzk9gDgyPC4zNDIBiAABCQkJDAsMGAANDRgyIRwhMgEuAP/AABEIAGIAAHcDASIAAhEAAQMRAf/EAB+wAAABBQCtAbAAAwAAAQIDBAUGBwgICQoLACC1EAACAAEDAwIEAwUFFAQEAC19AB8ABBEABRIhMUEGE1EAYQcicRQygZEAoQgjQrHBFVIA0fAkM2JyggkAChYXGBkaJSYAJygpKjQ1NjcAODk6Q0RFRkcASElKU1RVVlcAWFlaY2RlZmcAaGlqc3R1dncAeHl6g4SFhocAiImKkpOUlZYAl5iZmqKjpKUApqeoqaqys7QAtba3uLm6wsMAxMXGx8jJytIA09TV1tfY2doA4eLj5OXm5+gA6erx8vP09fYQ9/j5+"
    $bData &= "oFrAQADFwNrhmyMaxGAawIEBAgDBAeBawECdwABABARBAUhMQYSAEFRB2FxEyIyAIEIFEKRobHBAAkjM1LwFWJyANEKFiQ04SXxdwFtgmwjbIJyNgY2xzXaEAAMAwEAbwMRAAA/APn+iiigAg//AP8Q/yDSIA//2Q=="
    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __Preto(__PretoB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __Preto(__PretoB64($bData))
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_Preto
Func __PretoB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__PretoB64

Func __Preto($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf
    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))
    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__Preto

 

Link to comment
Share on other sites

@Nine I don't know how to do it this way or else I didn't understand what you meant.

EDITED: I'm researching sdl2.dll to see if I can display the images and if the cpu consumption will drop as well.

Edited by Belini
Link to comment
Share on other sites

I would do something like this :

#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <File.au3>

Opt("MustDeclareVars", True)
HotKeySet("{ESC}", Terminate)
Global $hGraphic, $aFile

Example()

Func Example()
  Local $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP), $hImage
  GUISetState(@SW_SHOW)
  $aFile = _FileListToArray(".\test", "*.jpg", $FLTA_FILES, True)
  ;_ArrayDisplay($aFile)

  _GDIPlus_Startup()
  $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

  While True
    For $i = 1 To $aFile[0]
      If IsString($aFile[$i]) Then
        $hImage = _GDIPlus_ImageLoadFromFile(".\test\" & $i & ".jpg")
        $aFile[$i] = _GDIPlus_ImageResize($hImage, @DesktopWidth, @DesktopHeight)
        _GDIPlus_ImageDispose($hImage)
      EndIf
      _GDIPlus_GraphicsDrawImage($hGraphic, $aFile[$i], 0, 0)
      Sleep(30)
    Next
  WEnd
EndFunc   ;==>Example

Func Terminate()
  For $i = 1 To $aFile[0]
    _GDIPlus_ImageDispose($aFile[$i])
  Next
  _GDIPlus_GraphicsDispose($hGraphic)
  _GDIPlus_Shutdown()
  Exit
EndFunc   ;==>Terminate

It will take a bit of space but in my test it is less than 860MB

Edited by Nine
Link to comment
Share on other sites

@Nine I tested it with your example and really _GDIPlus_ImageResize() is what makes the processing go up, when I remove the resize the cpu consumption drops by half around 20% but with resize it is 40% upwards.

@Andreik I need even if they are looped images, I just need to reduce the processing.

Edited by Belini
Link to comment
Share on other sites

Link to comment
Share on other sites

from the second loop onwards the processing really drops but in the first loop that is resizing the processing is high and the display of images is much slower, I need to do it with lower processing and the same speed since the first loop, any other tips not to be by GDI?

EDITED: I could even save the images in the same size as the desktop resolution so as not to use _GDIPlus_ImageResize() but then I couldn't use the same images in different resolutions.

Edited by Belini
Link to comment
Share on other sites

1 minute ago, Belini said:

from the second loop onwards the processing really drops but in the first loop that is resizing the processing is high and the display of images is much slower, I need to do it with lower processing and the same speed since the first loop, any other tips not to be by GDI?

Have you taken a look at Irrlicht yet?

Link to comment
Share on other sites

4 minutes ago, mutleey said:

Have you taken a look at Irrlicht yet?

I've never used Irrlicht but I'll research it, if you have an example and can post it, I'd appreciate it.

Link to comment
Share on other sites

28 minutes ago, Belini said:

any other tips not to be by GDI?

Nope, this is pretty much the best engine provided by Windows.  But you could try using a lower quality interpollation like $GDIP_INTERPOLATIONMODE_LOWQUALITY to see if it changes cpu usage (4th param of resize).  It seems that it is reducing a little on my machine.

Link to comment
Share on other sites

I would use GDI to display the images:

;Coded by UEZ build 2023-05-31
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

_GDIPlus_Startup()
Global $aGDIImages[170], $i, $hImage, $iW, $iH, $iW2, $iH2, $iW4, $iH4, $hObjOld, $bExit = False
ConsoleWrite("Loading images to memory..." & @CRLF)
For $i = 1 to 168
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test\" & $i & ".jpg")
    $aGDIImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _GDIPlus_ImageDispose($hImage)
Next
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Test\169.jpg")
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$iW2 = $iW / 2
$iH2 = $iH / 2
$iW4 = $iW / 4
$iH4 = $iH / 4
$aGDIImages[169] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
$aGDIImages[0] = 169
ConsoleWrite("Done" & @CRLF)
Global Const $hGUI = GUICreate("Test", $iW, $iH)
GUISetState()
Global Const $hDC = _WinAPI_GetDC($hGUI), _
             $hGfxDC = _WinAPI_CreateCompatibleDC($hDC)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$i = 1
Do
    $hObjOld = _WinAPI_SelectObject($hGfxDC, $aGDIImages[$i])
    _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY)
    ;_WinAPI_StretchBlt($hDC, $iW4, $iH4, $iW2, $iH2, $hGfxDC, 0, 0, $iW, $iH, $SRCCOPY) ;resize
    _WinAPI_SelectObject($hGfxDC, $hObjOld)
    $i += 1
    If $i > $aGDIImages[0] Then $i = 1
    If $bExit Then ExitLoop
Until Not Sleep(10)

For $i = 1 to $aGDIImages[0]
    _WinAPI_DeleteObject($aGDIImages[$i])
Next
_WinAPI_ReleaseDC($hGUI, $hDC)
_WinAPI_DeleteDC($hGfxDC)
_GDIPlus_Shutdown()

Func _Exit()
    $bExit = True
EndFunc

 

On my old Notebook the CPU usage is <1% and approx. 600 mb memory usage.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

22 minutes ago, UEZ said:

On my old Notebook the CPU usage is <1%.

@UEZ Anything below 20% would be fine with me, but I couldn't show the pictures using your example to be able to measure cpu usage.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...