Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/GZip with String
Required plugins for this example: MBS Compression Plugin, MBS Images Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/GZip with String
This example is the version from Sun, 17th Mar 2012.
Project "GZip with String.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() // create test file dim p as Picture = LogoMBS(5000) dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg") call f.SaveAsJPEGMBS(p,100) // compress test file dim g as new GZipFileMBS dim d as FolderItem = SpecialFolder.Desktop.Child("test.jpg.gz") dim b as BinaryStream = f.OpenAsBinaryFile(False) if g.Open(d,"w") then while not b.eof g.Write b.Read(1000000) wend g.Close b.Close end if // read to string dim bb as BinaryStream = d.OpenAsBinaryFile(False) dim compressed as string = bb.Read(bb.Length) // decompress in memory dim uncompressed as string = GZIPStringMBS(compressed) // display pic=JPEGStringToPictureMBS(uncompressed, true) End EventHandler
EventHandler Sub Paint(g As Graphics) if pic<>nil then g.DrawPicture pic, 0,0,Width,Height, 0,0, pic.Width, pic.Height end if End EventHandler
Function GZIPStringMBS(data as string) As string dim g as new GZipFileMBS const BlockSize=1000000 if g.OpenString(data) then dim parts(-1) as string while not g.eof dim s as string=g.Read(BlockSize) parts.Append s wend Return Join(parts,"") end if End Function
Property pic As Picture
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

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

MBS Xojo Plugins