Example: /Compression/GZip/GZip with String

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/GZip/GZip with String


Required plugins for this example: MBS Main Plugin, MBS Images Plugin, MBS Compression Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/GZip/GZip with String

This example is the version from Sun, 17th Mar 2012.

Project "GZip with String.xojo_binary_project"
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:

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


💬 Ask a question or report a problem