BackHomeAgain Posted May 8, 2021 Share Posted May 8, 2021 Error when attempting to use _GDIPlus_ImageGetWidth and Height in GUICtrlCreatePic I've used Dmitry Yudin (Lazycat) function _ImageGetInfo to get the width and height with no issues. I would rather use the GDIPlus width and height. Less include files. Local $iImage = _ImageGetInfo($iFile) Local $iWidth = _ImageGetParam($iImage, "Width") Local $iHeight = _ImageGetParam($iImage, "Height") Local $iImage = _GDIPlus_ImageLoadFromFile($iFile) Local $iWidth = _GDIPlus_ImageGetWidth($iImage) Local $iHeight = _GDIPlus_ImageGetHeight($iImage) $gHWnd = GUICreate("", $iWidth, $iHeight, -1, -1, 0x80000000) GUISetState() GUICtrlCreatePic($iFile, 0, 0, $iWidth, $iHeight) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gHWnd) _GDIPlus_GraphicsDrawImageRect($hGraphic, $iImage, 0, 0, $iWidth, $iHeight) GDIPlus requires more code and has no handle to pass into my Fade function using WinSetTrans Link to comment Share on other sites More sharing options...
Musashi Posted May 8, 2021 Share Posted May 8, 2021 (edited) 17 minutes ago, BackHomeAgain said: Error when attempting to use _GDIPlus_ImageGetWidth and Height in GUICtrlCreatePic This works for me : #include <GDIPlus.au3> _GDIPlus_Startup() Local $sFile = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Examples\GUI\Merlin.gif" Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) $gHWnd = GUICreate("", $iWidth, $iHeight, -1, -1, 0x80000000) GUISetState() GUICtrlCreatePic($sFile, 0, 0, $iWidth, $iHeight) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gHWnd) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $iWidth, $iHeight) Sleep(2000) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete($gHWnd) (Edit) @BackHomeAgain What error message appears in your SciTE console ? Edited May 8, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 9, 2021 Moderators Share Posted May 9, 2021 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
BackHomeAgain Posted May 9, 2021 Author Share Posted May 9, 2021 I copied your example code as is and ran the script. _GDIPlus_GraphicsDrawImageRect worked fine. GUICtrlCreatePic failed. "0" if picture cannot be created. Sorry I didn't get back to you sooner. Trying to figure out what's going on. Link to comment Share on other sites More sharing options...
Nine Posted May 9, 2021 Share Posted May 9, 2021 If you want to use a GIF file, I suggest you use my UDF : “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...
Musashi Posted May 9, 2021 Share Posted May 9, 2021 22 minutes ago, Nine said: If you want to use a GIF file, I suggest you use my UDF : Hi Nine ! Unfortunately, I don't know if this is a problem with .gif files at all. The OP has neither specified a file type nor attached a file. So I just took a file from the ..\Examples\GUI\ folder (merlin.gif) to make sure that it exists. @BackHomeAgain : You are right, GUICtrlCreatePic returns 0 ("picture cannot be created"). I didn't notice that, since the picture appears. I found the following thread, in which you participated yourself, by the way : why-guictrlcreatepic-doesnt-work-after-_gdiplus_startup Quote @UEZ : It doesn't work, because _GDIPlus_ImageLoadFromFile($file) is locking the file and GUICtrlCreatePic() cannot load it because it is locked by GDI+ function. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
BackHomeAgain Posted May 10, 2021 Author Share Posted May 10, 2021 Everything is up and running perfectly. Thanks for the help. How do you gurus find out about this stuff. 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