Picture slide show

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Picture slide show

Post by AndyGable » Monday 28th June 2021 11:53pm

Hi Everyone,

Does any have or know of a Picture slide show done in Gambas?

vuott
Posts: 97
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Picture slide show

Post by vuott » Tuesday 29th June 2021 8:38pm

...by using a Picture[ ] or Image[ ] array...

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Picture slide show

Post by AndyGable » Tuesday 29th June 2021 8:58pm

Could that be controlled by a timer? To say loop though each pic and show it for 20 seconds at a time?

vuott
Posts: 97
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Picture slide show

Post by vuott » Tuesday 29th June 2021 9:22pm

Of course, try it. :)

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Picture slide show

Post by AndyGable » Tuesday 29th June 2021 9:31pm

I will thanks for the advice

User avatar
BruceSteers
Posts: 652
Joined: Thursday 23rd July 2020 5:20pm

Re: Picture slide show

Post by BruceSteers » Tuesday 29th June 2021 10:15pm

Should be simple. Something like..
Add a PictureBox called PictureBox1 and a timer called PictureTimer...
Public ListPos As Integer
Public dirList As String[]

Public Sub startshow(Folder As String)

ListPos = 0
dirList = []
Dim files as String[] = Dir(Folder)
For Each s As String In files
Dim ext As String = File.Ext(s)
If ext = "jpg" Or Ext = "png" Then dirList.Add(s)
Next

PictureTimer.Start
End

Public Sub PictureTimer_Timer()
PictureBox1.Picture = Picture.Load(dirList[ListPos])
If Listpos = dirList.Max then ListPos = 0 Else Inc ListPos
End
Something like that
(I typed this on my phone at work so could be errors, just an example)
Wishing well
Bruce

If at first you don't succeed , try it differently.

AndyGable
Posts: 137
Joined: Wednesday 02nd December 2020 12:11am
Location: England
Contact:

Re: Picture slide show

Post by AndyGable » Wednesday 30th June 2021 11:30am

Thanks Bruce it will give me something to start with

User avatar
cogier
Site Admin
Posts: 756
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Picture slide show

Post by cogier » Wednesday 30th June 2021 1:53pm

Run this code in a new Graphical Application. It assumes you have some .jpg files in your Pictures folder.
sPath As String = User.Home &/ "Pictures"
sPictures As String[] = Dir(sPath, "*.jpg")
iCount As Integer
PictureBox1 As PictureBox
Timer1 As Timer

Public Sub Form_Open()

  BuildForm

End

Public Sub Timer1_Timer()

  Try PictureBox1.Picture = Picture.Load(sPath &/ sPictures[iCount])
  Me.Text = sPictures[iCount]
  Inc iCount
  If iCount = sPictures.Count Then iCount = 0

End

Public Sub BuildForm()

  With Me
    .Height = 700
    .Width = 1000
    .Padding = 5
    .Arrangement = Arrange.Vertical
    .Center
  End With

  With PictureBox1 = New PictureBox(Me) As "PictureBox1"
    .Expand = True
    .Mode = PictureBox.Contain
    .Alignment = Align.Center
  End With

  With Timer1 = New Timer As "Timer1"
    .Enabled = True
    .Delay = 2000
  End With

End

Post Reply