Jump to content
Sign in to follow this  
Tukata

Image display problem

Recommended Posts

Tukata

Hi

I use "GUICtrlCreatePic" and need to replace the image few times and display the original dimension of each image. The help file says: "If you want to have a picture having the same size as the file content just use width=height=0." Whatever I tried I failed. Please help.

Another question, Is there a way to use "SplashImageOn" instead and how do I display original dimensions ?

And last question: Is there a way to click on the SplashImage to activate the "SplashOff()" ?

thank you in advance

tukata

Share this post


Link to post
Share on other sites
BrettF

Hi there,

In response to your first question:

#include <GDIPlus.au3>

Dim $image[2]
$image[0] = @ScriptDir & "\loginbox.jpg" ; http://www.signa5.com/IMG/loginbox/loginbox.jpg 256px × 162px
$image[1] = @ScriptDir & "\worldcam.jpg" ; http://www.signa5.com/IMG/worldcam/worldcam.jpg 550px × 413px

;This will download those two images into your script dir.  Comment after running it once.
;$return = InetGet ("http://www.signa5.com/IMG/loginbox/loginbox.jpg", @ScriptDir & "\loginbox.jpg", 0)
;If $return > 0 Then ConsoleWrite ("Downloaded Image OK!" & @CRLF)
;$return = InetGet ("http://www.signa5.com/IMG/worldcam/worldcam.jpg", @ScriptDir & "\worldcam.jpg", 0)
;If $return > 0 Then ConsoleWrite ("Downloaded Image OK!" & @CRLF)

Global $hGUI = GUICreate ("Test", 800, 600)

$hPic = GUICtrlCreatePic ($image[1], 10, 10, 0 ,0)

GUISetState ()

MsgBox (0, "GUI Created!", "Press OK to change image")

_ChangeImage ($image[0])

MsgBox (0, "Image Changed!", "Press OK to close")

Func _ChangeImage ($sLocation)
    GUICtrlSetImage ($hPic, $sLocation)
    _GDIPlus_Startup ()
    $hImage = _GDIPlus_ImageLoadFromFile($sLocation)
    $width = _GDIPlus_ImageGetWidth($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)
    GUICtrlSetPos ($hPic, 10, 10, $width, $height)
    _GDIPlus_ImageDispose ($hImage)
    _GDIPlus_ShutDown ()
EndFunc

You should be able to work out question two from the above example. With question three, just make it yourself... Not too difficult. Probably a few examples scattered around the forums as well.

Cheers,

Brett

Share this post


Link to post
Share on other sites
Tukata

BrettF !

Thank you.

You have been very helpful.

tukata

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  

×