Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Images/GIF/Gif Test
Function:
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/GIF/Gif Test
This example is the version from Thu, 6th Apr 2016.
Project "Gif Test.rbp"
FileTypes
Filetype image/gif
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() Timer1.mode=2 End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Open() Load me, "ball1.gif" End EventHandler
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
EventHandler Sub Open() Load me, "ball2.gif" End EventHandler
End Control
Control Canvas3 Inherits Canvas
ControlInstance Canvas3 Inherits Canvas
EventHandler Sub Open() Load me, "ball3.gif" End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() run End EventHandler
End Control
Control Canvas4 Inherits Canvas
ControlInstance Canvas4 Inherits Canvas
EventHandler Sub Open() Load me, "ball4.gif" End EventHandler
End Control
Control Canvas5 Inherits Canvas
ControlInstance Canvas5 Inherits Canvas
EventHandler Sub Open() Load me, "ball5.gif" End EventHandler
End Control
Control Canvas6 Inherits Canvas
ControlInstance Canvas6 Inherits Canvas
EventHandler Sub Open() Load me, "ball6.gif" End EventHandler
End Control
Control out Inherits Canvas
ControlInstance out Inherits Canvas
End Control
Control Canvas7 Inherits Canvas
ControlInstance Canvas7 Inherits Canvas
EventHandler Sub Open() Load me, "ball7.gif" End EventHandler
End Control
Control Canvas8 Inherits Canvas
ControlInstance Canvas8 Inherits Canvas
EventHandler Sub Open() Load me, "ball7.gif" End EventHandler
End Control
Control Canvas9 Inherits Canvas
ControlInstance Canvas9 Inherits Canvas
EventHandler Sub Open() Load me, "ball8.gif" End EventHandler
End Control
EventHandler Sub Open() dim g as GifMBS dim f as FolderItem dim pic as Picture f=FindFile("test.gif") g=f.OpenAsGIFMBS if g<>nil then pic=g.MakeFirstPicture if pic<>Nil then 'width=pic.Width 'Height=pic.Height pic.Mask.Graphics.DrawPicture g.MakeFirstMask,0,0 out.Backdrop=pic else out.Backdrop=nil end if end if End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Protected Sub load(c as canvas, name as string) dim g as GifMBS dim f as FolderItem dim pic as Picture c.HelpTag=name f=FindFile(name) g=f.OpenAsGIFMBS if g<>nil then pic=g.MakeFirstPicture if pic<>Nil then pic.Mask.Graphics.DrawPicture g.MakeFirstMask,0,0 c.Backdrop=pic end if end if End Sub
Sub run() dim s as string dim b as BinaryStream dim g as GifMBS dim f as FolderItem dim pic as Picture f=FindFile("test.gif") b=f.OpenAsBinaryFile(false) s=b.Read(b.Length) b.Close s=leftb(s,rnd*(1+lenb(s))) f=FindFile("test_.gif") b=f.CreateBinaryFile("image/gif") b.Write s b.Close g=f.OpenAsGIFMBS if g=nil then out.Backdrop=nil else pic=g.MakeFirstPicture if pic<>Nil then pic.Mask.Graphics.DrawPicture g.MakeFirstMask,0,0 out.Backdrop=pic else out.Backdrop=nil end if end if End Sub
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins