Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/JPEG movie
Required plugins for this example: MBS Images Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/JPEG/JPEG movie
This example is the version from Sun, 1st Apr 2017.
Project "JPEG movie.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control RunButton Inherits PushButton
ControlInstance RunButton Inherits PushButton
EventHandler Sub Action() dim f as FolderItem = GetSaveFolderItem(FileTypes1.Quicktime, "test.mov") if f = nil then Return end if dim m as new JPEGMovieMBS m.Height = movieHeight m.Width = movieWidth m.SecondsPerFrame = 1.0 dim u as integer = List.ListCount-1 for i as integer = 0 to u dim s as string = List.RowTag(i) m.AddFrame s next dim MovieData as string = m.BuildMovie dim b as BinaryStream = BinaryStream.Create(f, true) b.Write MovieData Exception ie as IOException MsgBox "Failed to write movie file."+EndOfLine+EndOfLine+ie.message Exception uoe as UnsupportedOperationException MsgBox "Building movie failed"+EndOfLine+EndOfLine+uoe.message End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change() CheckButton End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean if asc(key) = 8 or asc(key) = 127 then if me.ListIndex >= 0 then me.RemoveRow me.ListIndex Return true end if end if End EventHandler
End Control
Control AddButton Inherits PushButton
ControlInstance AddButton Inherits PushButton
EventHandler Sub Action() dim f as FolderItem = GetOpenFolderItem(FileTypes1.Jpeg) if f = nil then Return AddFile f CheckButton End EventHandler
End Control
Control SelectButton Inherits PushButton
ControlInstance SelectButton Inherits PushButton
EventHandler Sub Action() dim f as FolderItem = SelectFolder if f = nil then Return AddFolder f CheckButton End EventHandler
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) do if obj.FolderItemAvailable then dim file as FolderItem = obj.FolderItem if file <> nil then Add file end if end if loop until not obj.NextItem CheckButton End EventHandler
EventHandler Sub Open() AcceptFileDrop FileTypes1.Jpeg End EventHandler
Sub Add(file as FolderItem) if file.Directory then AddFolder file else dim n as string = file.name if Right(n,4) = ".jpg" or Right(n,5) = ".jpeg" then AddFile file end if end if End Sub
Sub AddFile(f as FolderItem) dim b as BinaryStream = BinaryStream.Open(f) dim s as string = b.Read(b.Length) dim j as new JPEGImporterMBS j.Data = s j.Import dim p as Picture = j.Picture if p <> nil then List.AddRow f.DisplayName, str(p.Width), str(p.Height) List.RowTag(List.LastIndex) = s movieWidth = p.Width movieHeight = p.Height end if End Sub
Sub AddFolder(f as FolderItem) dim c as integer = f.Count for i as integer = 1 to c dim file as FolderItem = f.TrueItem(i) if file.Visible then add file end if next End Sub
Sub CheckButton() RunButton.Enabled = List.ListCount > 0 End Sub
Property movieHeight As Integer
Property movieWidth As Integer
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Filetype image/jpeg
Filetype video/quicktime
End FileTypes1
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Images Plugin.

MBS Xojo tutorial videos