Jump to content

Slide Show Maker


DaProgrammer
 Share

Recommended Posts

This is the Small Version, i won't release the code for the Gui Version for now, though i highly reccomend Downloading it :)

just put the script in the same folder with some .jpg files and run.

#region - Settings
HotKeySet("{ESC}", "Terminate")
Opt("WinTitleMatchMode", 3)

;Error Msg if no .jpg files were found
If Not FileExists(@ScriptDir & "\*.jpg") Then
    MsgBox(16 + 262144, "Error", 'No JPG files were found')
    Exit
EndIf
#endregion
;
#region - Load Images to Array
;Count the number of files
Local $i = 0
$search = FileFindFirstFile(@ScriptDir & "\" & "*.jpg")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $i = $i + 1
WEnd
FileClose($search)

;Define an Array to contain the files and ratio
Global $Files[$i + 1][2]
$Files[0][0] = $i

;Load file names and image ratio to the Array
$i = 0
$search = FileFindFirstFile(@ScriptDir & "\" & "*.jpg")
While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $sizee = _GetJpegSize(@ScriptDir & "\" & $file)
    $i = $i + 1
    $Files[$i][0] = "\" & $file
    $Files[$i][1] = $sizee[0] / $sizee[1]
WEnd
FileClose($search)
#endregion
;
#region - Main
$Location = 1

;Create GUI (gray Background)
Global $FullGui = GUICreate(@ScriptName & " FullScreen_bg", @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000, 0x00000008)
GUISetState(@SW_SHOW, $FullGui)

;Show 1st Picture
ShowPic($Location)

;Run the Picture change Func every 5000 ms.
AdlibEnable("Nextt", 5000)

;Loop so Program wont shut down
While 1
    Sleep(1000)
WEnd

Func ShowPic($i)
   ;Fade out old Picture
    For $x = 254 To 1 Step - 5
        WinSetTrans(@ScriptName & "FullScreen_img", "", $x)
    Next
    SplashOff()
    
   ;Create new Picture out of screen --> set trans to 0 --> move back to center
    $ImageSize = GetNewImageSize($Files[$i][1], @DesktopWidth, @DesktopHeight)
    SplashImageOn(@ScriptName & "FullScreen_img", @ScriptDir & "\" & $Files[$i][0], $ImageSize[0], $ImageSize[1], 5000, 5000, 1)
    WinSetTrans(@ScriptName & "FullScreen_img", "", 0)
    WinMove(@ScriptName & "FullScreen_img", "", (@DesktopWidth - $ImageSize[0]) / 2, (@DesktopHeight - $ImageSize[1]) / 2)
    
   ;Fade in new Picture
    For $x = 1 To 254 Step 5
        WinSetTrans(@ScriptName & "FullScreen_img", "", $x)
    Next
EndFunc  ;==>ShowPic

;Func written by me :) , Returns a new Resolution based on area to work with
;and original resolution ratio --> in a 2dim Array
Func GetNewImageSize($OrigRatio, $WorkAreaWidth, $WorkAreaHight)
    Local $NewImageSize[2]
    If $OrigRatio < $WorkAreaWidth / $WorkAreaHight Then
        $NewImageSize[0] = $WorkAreaHight * $OrigRatio
        $NewImageSize[1] = $WorkAreaHight
    Else
        $NewImageSize[0] = $WorkAreaWidth
        $NewImageSize[1] = $WorkAreaWidth / $OrigRatio
    EndIf
    Return $NewImageSize
EndFunc  ;==>GetNewImageSize

;Shows Next picture every 5000 ms (as specified in the AdlibEnable above)
Func Nextt()
    If $Location < $Files[0][0] Then
        $Location = $Location + 1
    Else
        $Location = 1
    EndIf
    ShowPic($Location)
EndFunc  ;==>Nextt

;Gess what this does ???
Func Terminate()
    Exit
EndFunc  ;==>Terminate

#endregion
;
#region - JPEG
;===============================================================================
;
; Description:    Return JPEG size
; Parameter(s):  File name
; Requirement(s):   None
; Return Value(s):  On Success - array with width and height
;                  On Failure empty string and sets @ERROR:
;                      1 - File is not valid JPEG
;                      2 - Info not found
; Author(s):        YDY (Kot) <mpc@nm.ru>
; Version:        1.1.00
; Date:          10.08.2004
; Note(s):        None
;
;===============================================================================
Func _GetJpegSize($file)
    Local $size[2]
    Local $fs, $pos = 3

    $fs = FileGetSize($file)

    While $pos < $fs
        $data = _FileReadAtOffsetHEX($file, $pos, 4)
        If StringLeft($data, 2) = "FF" Then
            If StringInStr("C0 C2 CA C1 C3 C5 C6 C7 C9 CB CD CE CF", StringMid($data, 3, 2)) Then
                $seg = _FileReadAtOffsetHEX($file, $pos + 5, 4)
                $size[1] = Dec(StringLeft($seg, 4))
                $size[0] = Dec(StringRight($seg, 4))
                Return ($size)
            Else
                $pos = $pos + Dec(StringRight($data, 4)) + 2
            EndIf
        Else
            ExitLoop
        EndIf
    WEnd
    SetError(2)
    Return ("")
EndFunc  ;==>_GetJpegSize
;
Func _FileReadAtOffsetHEX($file, $offset, $bytes)
    Local $tfile = FileOpen($file, 0)
    Local $tstr = ""
    FileRead($tfile, $offset - 1)
    For $i = $offset To $offset + $bytes - 1
        $tstr = $tstr & Hex(Asc(FileRead($tfile, 1)), 2)
    Next
    FileClose($tfile)
    Return ($tstr)
EndFunc  ;==>_FileReadAtOffsetHEX
#endregion

The Gui Version is in the .zip file attached, heres a Screenshot.

Posted Image

SlideShow Maker (with GUI UI)

Instructions

Place all .jpg and .mp3 files in a folder named "Files"

Features

Plays .mp3 files

Normal SlideShow + FullScreen SlideShow

SlideShow delay slidebar

Save Pictures to folder feature (very usefull for making gift CD with photos)

Pretty buttons ;)

Hotkeys

LEFT = Previous picture

RIGHT = Next Picture

SPACE = Play / Pause Slideshow

ENTER = Go to fullscreen mode

ESC = Exit

Slide_Show_1.2.zip

Edited by DaProgrammer
Link to comment
Share on other sites

nice udf ;) and nice looking gui

u saw The Gui Version or u 1 of those who are afraid to test .exe files :) ?

I think he meant he looks forward to seeing the code since you mentioned that you highly recommend showing the code.

A decision is a powerful thing
Link to comment
Share on other sites

Nice job! about the gui? why didnt you supply the source to that too??

Its very messy, split into many files, many icon files, modefied XSkin, and a shitload of a mess that i made :)

the .exe works and i aint got the powa to clean the soure !

unless some1 reports a bug or something to fix, by this time tommorow i'll probably be off to my next project.

just need to figure out what it will be, LOL

p.s. some ideas will be nice

Edited by DaProgrammer
Link to comment
Share on other sites

Its very messy, split into many files, many icon files, modefied XSkin, and a shitload of a mess that i made :)

the .exe works and i aint got the powa to clean the soure !

unless some1 reports a bug or something to fix, by this time tommorow i'll probably be off to my next project.

just need to figure out what it will be, LOL

p.s. some ideas will be nice

Maybe if you posted the source, its more than likely someone will followup with clean version of your code.

Just a suggestion.

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

I get an error, maybe what was related to Generators.

I put the GUI version of the program in a folder with 104 of .JPG Files.

It said it didnt find any... Is the file search in your program case sensitive(.jpg it will find, .JPG it wont)?

It doesnt do that with the source..

Link to comment
Share on other sites

I get an error, maybe what was related to Generators.

I put the GUI version of the program in a folder with 104 of .JPG Files.

It said it didnt find any... Is the file search in your program case sensitive(.jpg it will find, .JPG it wont)?

It doesnt do that with the source..

if u read what it says 'No JPG files were found in the Folder: "Files"' than ull see u have to put the jpg in a folder named "Files"

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...