Jump to content
Sign in to follow this  
Jex

_GDIPlus_ImageGetWidth&Height problem

Recommended Posts

Jex
therks

$hImage = "Autoit.jpg"

That's not a handle to the image, that's a string. :P

$sImageFile = "Autoit.jpg"
$hImage = _GDIPlus_ImageLoadFromFile($sImageFile)

Try that.

Share this post


Link to post
Share on other sites
smashly

Hi

It's not a bug that I can see , your not using the _GDIPlus function correctly..

_GDIPlus_ImageGetWidth() and _GDIPlus_ImageGetHeight() work with the handle to an image object not an image file.

You need to load the file as an image object and use the handle of the object.

Cheers

Edit: saunders beat me to it.

Edited by smashly

Share this post


Link to post
Share on other sites
Jex

Thanks for helps :P

Edit :

But if im use "_GDIPlus_ImageLoadFromFile($Image)"

"GUICtrlCreatePic" not work.

Example :

That work without "_GDIPlus_ImageLoadFromFile($Image)" :

#include <GDIPlus.au3>

_GDIPlus_Startup()
$Image = "Autoit.jpg"
;$hImage = _GDIPlus_ImageLoadFromFile($Image)
$Width = 500;_GDIPlus_ImageGetWidth($hImage)
$Height = 500;_GDIPlus_ImageGetHeight($hImage)
GUICreate("Test", $Width, $Height)
GUICtrlCreatePic($Image, 0, 0, $Width, $Height)
GUISetState()
Sleep(3000)oÝ÷ Ø­¶­p¢¹0ØjºFåºÂ&j¡§E®W´ß¢&jªºZºÚ"µÍÚ[ÛYH  ÑÑTË]LÉÝÂÑÑT×ÔÝ

BÌÍÒ[XYÙHH  ][ÝÐ]]Ú]É][ÝÂÌÍÚ[XYÙHHÑÑT×Ò[XYÙSØYÛQ[J ÌÍÒ[XYÙJBÌÍÕÚYHÑÑT×Ò[XYÙQÙ]ÚY
    ÌÍÚ[XYÙJBÌÍÒZYÚHÑÑT×Ò[XYÙQÙ]ZYÚ
    ÌÍÚ[XYÙJBÕRPÜX]J  ][ÝÕÝ    ][ÝË  ÌÍÕÚY   ÌÍÒZYÚ
BÕRPÝÜX]TXÊ ][ÝÐ]]Ú]É][ÝË ÌÍÕÚY   ÌÍÒZYÚ
BÕRTÙ]Ý]J
BÛY
Ì
Edited by Jex

Share this post


Link to post
Share on other sites
therks

Well I must say, that is rather odd. If the image is loaded with the GDI function you are unable to use it with the picture control... hmm, I guess you'll have to dispose it?

Hmm.... yup that works. Give this a try.

#include <GDIPlus.au3>

_GDIPlus_Startup()
$Image = "Autoit.jpg"
$hImage = _GDIPlus_ImageLoadFromFile($Image)
$Width = _GDIPlus_ImageGetWidth($hImage)
$Height = _GDIPlus_ImageGetHeight($hImage)
_GDIPlus_ImageDispose($hImage)
GUICreate("Test", $Width, $Height)
GUICtrlCreatePic("Autoit.jpg", 0, 0, $Width, $Height)
GUISetState()
Sleep(3000)

Not really sure why it won't display the image if you don't release it, but I'm guessing it's an issue with the file already being in use.

Share this post


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
Sign in to follow this  

×