Picture slide show

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Picture slide show

Post by AndyGable »

Hi Everyone,

Does any have or know of a Picture slide show done in Gambas?
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Picture slide show

Post by vuott »

...by using a Picture[ ] or Image[ ] array...
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Picture slide show

Post by AndyGable »

Could that be controlled by a timer? To say loop though each pic and show it for 20 seconds at a time?
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Picture slide show

Post by vuott »

Of course, try it. :)
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Picture slide show

Post by AndyGable »

I will thanks for the advice
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Picture slide show

Post by BruceSteers »

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)
If at first you don't succeed , try doing something differently.
BruceS
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Picture slide show

Post by AndyGable »

Thanks Bruce it will give me something to start with
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Picture slide show

Post by cogier »

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