Jump to content

Need Help With Image Display


 Share

Recommended Posts

Hello. I have recently gotten AutoIt and so far I love the language. I have been working on something lately that I just can't seem to get right. I want to flash different .jpg images at 15 millesecond intervals. I have already tried doing this with labels and failed, although I'm sure it must be the easiest way. So far what I have is this:

#include <GDIPlus.au3>

#include <GuiConstantsEx.au3>

Opt("MustDeclareVars", 1)

Global $hGUI, $hImage, $hGraphic

$hGUI = GUICreate("Show PNG", 2048, 1152)

GUISetState()

_GDIPlus_StartUp()

Soundplay(@WindowsDir & "\media\ravebreak.mp3",1)

$hImage = _GDIPlus_ImageLoadFromFile("C:\rave\rave yellow.jpg")

Sleep(15)

$hImage = _GDIPlus_ImageLoadFromFile("C:\rave\rave green.jpg")

SLeep(15)

$hImage = _GDIPlus_ImageLoadFromFile("C:\rave\rave red.jpg")

SLeep(15)

$hImage = _GDIPlus_ImageLoadFromFile("C:\rave\rave purple.jpg")

SLeep(15)

$hImage = _GDIPlus_ImageLoadFromFile("C:\rave\rave blue.jpg")

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)

do

until GUIGetMsg() = $GUI_EVENT_CLOSE

_GDIPlus_GraphicsDispose($hGraphic)

_GDIPlus_ImageDispose($hImage)

_GDIPlus_ShutDown()

Basicly what is happening is it is just showing a blank full screen that has no colour. I had the blue shade working at one point but I don't know what happened. The music plays fine but the colours don't even display. I would greatly appreciate it if someone could tell me how to do this with labels, or if you want, correct my piece of crap. Thank you very much for tolerating my newbieness. I'm sure I'll get the hang of this language eventually but for now I need some help.

Link to comment
Share on other sites

Hi,

I sorta cheated as I didn't want to type out the names of the .jpg files.

So I just look in C:\Rave\ directory and see if there's any .jpg files if so then start flashing them on the screen.

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>

;Set the path to where the .jpg files are
Global $sPicPath = "C:\rave\"

;List the found .jpg's into an array, if no .jpg's found then exit the script
Global $aPic = _FileListToArray($sPicPath, "*.jpg", 1)
If @error Then Exit

Global $hGui, $hGraphic

SoundPlay(@WindowsDir & "\media\ravebreak.mp3")

$hGui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetState()

_GDIPlus_Startup()

;Get Graphic context of the GUI
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)

;Load .jpg's and get the handles for the images into the array
For $i = 1 To $aPic[0]
    $aPic[$i] = _GDIPlus_ImageLoadFromFile($sPicPath & $aPic[$i])
Next

;Display found .jpg's by looping through the array of image handles we loaded.
Do
    For $i = 1 To $aPic[0]
        _GDIPlus_GraphicsDrawImage($hGraphic, $aPic[$i], 0, 0)
        Sleep(15)
    Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE


;Clean up resources on exit.
_GDIPlus_GraphicsDispose($hGraphic)
For $i = 1 To $aPic[0]
    _GDIPlus_ImageDispose($aPic[$i])
Next
_GDIPlus_Shutdown()

Cheers

Link to comment
Share on other sites

Hi,

I sorta cheated as I didn't want to type out the names of the .jpg files.

So I just look in C:\Rave\ directory and see if there's any .jpg files if so then start flashing them on the screen.

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>

;Set the path to where the .jpg files are
Global $sPicPath = "C:\rave\"

;List the found .jpg's into an array, if no .jpg's found then exit the script
Global $aPic = _FileListToArray($sPicPath, "*.jpg", 1)
If @error Then Exit

Global $hGui, $hGraphic

SoundPlay(@WindowsDir & "\media\ravebreak.mp3")

$hGui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetState()

_GDIPlus_Startup()

;Get Graphic context of the GUI
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)

;Load .jpg's and get the handles for the images into the array
For $i = 1 To $aPic[0]
    $aPic[$i] = _GDIPlus_ImageLoadFromFile($sPicPath & $aPic[$i])
Next

;Display found .jpg's by looping through the array of image handles we loaded.
Do
    For $i = 1 To $aPic[0]
        _GDIPlus_GraphicsDrawImage($hGraphic, $aPic[$i], 0, 0)
        Sleep(15)
    Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE


;Clean up resources on exit.
_GDIPlus_GraphicsDispose($hGraphic)
For $i = 1 To $aPic[0]
    _GDIPlus_ImageDispose($aPic[$i])
Next
_GDIPlus_Shutdown()

Cheers

Thanks so much man, it works perfectly ;)

I hope to see you again on these forums, thanks a lot for the help.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...