image slide show

Blitz3D Forums/Blitz3D Beginners Area/image slide show

Hi I was wondering how do you take a image for example

h1=loadimage=( "Dm1.png" )

;wait a while for it to change.

h2=loadimage=( "Dm2.png" )


Do I use millisecs to do this if so how?

Wouldn't it be easier to put all images in a array and pass them using a while loop.

Just of the top of my head...


eg.


Dim images$(5)

images$(0) = "pic1.jpg"
images$(1) = "pic2.jpg"
images$(2) = "pic3.jpg"
images$(3) = "pic4.jpg"
images$(4) = "pic5.jpg"

Dim slides(5)

Global index=0;


;Load images on initialisation.

Function InitialiseSlideShow()

   index = 0;

   while(index < 5)
      sildes(index) = LoadImage( images$(index) )
      index=index+1;
   Wend

End Function

; Show the loaded images.
Function ShowSlides(time)

   index=0;

   while(index < 5)
      DrawImage( 0,0, slides(index) )
      Flip
      Delay(time)
      index=index+1
   Wend

End Function




You then call the initialise routine before main loop and call the show routine in your main loop (while Not KeyHit(1)) - defining the interval you want to wait (in ms).


Graphics3D 800,600,16

SetBuffer BackBuffer()
 
Dim images$(3)

images$(0) = "Dm1.png"
images$(1) = "Dm2.png"
images$(2) = "Dm3.png"

Dim slides(3)

Global index=3;

While Not KeyHit(1)

; Show the loaded images.
index=3

If (index < 3)=True Then  
DrawImage( 0,0, slides(index) )
Delay(time)
index=index+1
Flip     
EndIf 
Wend 
End 

;Load images on initialisation.

Function InitialiseSlideShow()

index = 3;

While(index < 3)
slides(index) = LoadImage( images$(index) )
index=index+1;
Wend

End Function



A little better...

Graphics3D 800,600,16

SetBuffer BackBuffer()
 

Const	NOF_SLIDES = 3; 	Change this to how many pics you have

Dim images$(NOF_SLIDES)
Dim slides(NOF_SLIDES)

images$(0) = "Dm1.png"
images$(1) = "Dm2.png"
images$(2) = "Dm3.png"


Global index=0;
Global timer=0;

; Load before main loop

InitialiseSlideShow()

; -------------------
; Main program
; -------------------

timer = MilliSecs();

While Not KeyHit(1)

	Cls
	
	UpdateSlides(500) 

	ShowSlides(index)	

	Flip     

Wend

End


; - Functions here on in -

; ------------------------------
; Load images on initialisation.
; ------------------------------

Function InitialiseSlideShow()

	index = 0;

	While(index < NOF_SLIDES)
		slides(index) = LoadImage( images$(index) )
		index=index+1;
	Wend

	index =0;

End Function


; -----------------------
; Update the slide index when timer has elapsed
; -----------------------

Function UpdateSlides( wait_time )

	; Check that the tiime has elapsed before updating image.
	If(MilliSecs() < (timer + wait_time)) Return;		

	timer=MilliSecs()

	If (index < NOF_SLIDES-1) Then  
		index=index+1
	Else
		index=0;
	EndIf 

End Function

; -----------------------
; Show the current slide
; -----------------------

Function ShowSlides( idx )

	DrawImage(slides(idx), 0, 0 );
	
End Function



Hope this helps...

Your code was excellent thanks :)

No probs.