Belini Posted May 31, 2023 Share Posted May 31, 2023 (edited) 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 expandcollapse popup#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 May 31, 2023 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 Have you tried GDI+ ? Just tested on my machine, and I am close to 2% cpu, but I must admit, it is a powerful comp... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 With GDI I didn't test it, could you give an example of how to do it in GDI? My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 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 Belini 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 @Nine dropped to 20% but the image doesn't take up the whole screen expandcollapse popup#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 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 use _GDIPlus_ImageResize to change it to your wanted size. Dont forget to dispose the new image... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted May 31, 2023 Share Posted May 31, 2023 $Form = GUICreate("Video_jpg", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) I hope this is not your way to display jpg files like a video. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 @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 expandcollapse popup#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 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 You could save the resized images ($hImage2) into an array, after first pass, only show the right size images ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 (edited) @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 May 31, 2023 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 (edited) I would do something like this : expandcollapse popup#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 May 31, 2023 by Nine Zedna and argumentum 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted May 31, 2023 Share Posted May 31, 2023 (edited) @Belini do you really consider rendering images better than making a short AVI from your files or whatever video format and play it normally? @Nine 6% CPU and 1300 MB on my PC Edited May 31, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 (edited) @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 May 31, 2023 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 @Belini This is why my last example only do resize once. Then you should see a large drop in cpu %. But you should also notice an increase in memory usage. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 (edited) 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 May 31, 2023 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
mutleey Posted May 31, 2023 Share Posted May 31, 2023 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 More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 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. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted May 31, 2023 Share Posted May 31, 2023 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
UEZ Posted May 31, 2023 Share Posted May 31, 2023 (edited) I would use GDI to display the images: expandcollapse popup;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 May 31, 2023 by UEZ Zedna 1 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 More sharing options...
Belini Posted May 31, 2023 Author Share Posted May 31, 2023 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. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now