Jump to content

Recommended Posts

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 post
Share on other sites
Posted (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 by Musashi

Musashi-C64.png

"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 post
Share on other sites
  • Moderators

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 post
Share on other sites

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 post
Share on other sites
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.

Musashi-C64.png

"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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...