Platforms to show: All Mac Windows Linux Cross-Platform

Back to LZ4MBS module.

LZ4MBS.Compress(InputData as MemoryBlock) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a MemoryBlock.
Example
// some 10 million zeros will compress well
Dim m As New MemoryBlock(100000000)

// compress
Dim c As MemoryBlock = LZ4MBS.Compress(m)

// decompress
Dim d As MemoryBlock = LZ4MBS.Decompress(c)

// and check
If d.Size = m.size Then
MsgBox "Sizes match"
Else
MsgBox "Sizes don't match"
End If

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

See also:

LZ4MBS.Compress(InputData as Ptr, Size as Integer) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses data in ptr.

Same as memoryblock version, but with ptr parameter, so you can pass ptr with size.
Works also for passing memoryblocks and a custom size.

See also:

LZ4MBS.Compress(InputData as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a string.
Example
Dim m As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor site amat."

// make sure encoding is set
m = ConvertEncoding(m, encodings.UTF8)

// compress
Dim c As String = LZ4MBS.Compress(m)

// decompress
Dim d As String = LZ4MBS.Decompress(c)

// set encoding after decompressing
d = DefineEncoding(d, encodings.UTF8)

// and check
If d = m Then
MsgBox "Text match"
Else
MsgBox "Text doesn't match"
End If

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

See also:

LZ4MBS.CompressFast(InputData as MemoryBlock, Acceleration as Integer = 1) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a memoryblock.

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

Same as Compress(), but allows selection of "acceleration" factor.
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
An acceleration value of "1" is the same as regular Compress()
Values <= 0 will be replaced by AccelerationDefault (currently = 1).

See also:

LZ4MBS.CompressFast(InputData as Ptr, Size as Integer, Acceleration as Integer = 1) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses data in ptr.

Same as memoryblock version, but with ptr parameter, so you can pass ptr with size.
Works also for passing memoryblocks and a custom size.

See also:

LZ4MBS.CompressFast(InputData as string, Acceleration as Integer = 1) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a string.

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

Same as Compress(), but allows selection of "acceleration" factor.
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
An acceleration value of "1" is the same as regular Compress()
Values <= 0 will be replaced by AccelerationDefault (currently = 1).

See also:

LZ4MBS.CompressHC(InputData as MemoryBlock, compressionLevel as Integer = 9) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a memoryblock with high compression.
Example
// lets make some data to compress
Dim p As Picture = LogoMBS(500)
Dim m As MemoryBlock = p.GetData(Picture.FormatBMP)

// compress
Dim c1 As MemoryBlock = LZ4MBS.Compress(m)
Dim c2 As MemoryBlock = LZ4MBS.CompressHC(m, LZ4MBS.CompressionLevelMin)
Dim c3 As MemoryBlock = LZ4MBS.CompressHC(m, LZ4MBS.CompressionLevelDefault)
Dim c4 As MemoryBlock = LZ4MBS.CompressHC(m, LZ4MBS.CompressionLevelOptMin)
Dim c5 As MemoryBlock = LZ4MBS.CompressHC(m, LZ4MBS.CompressionLevelMax)


MsgBox _
Str(c1.Size)+" normal"+EndOfLine+_
Str(c2.size)+" min"+EndOfLine+_
Str(c3.size)+" default"+EndOfLine+_
Str(c4.size)+" opt min"+EndOfLine+_
Str(c5.size)+" max"

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

Compression level, with # being any value from 1 to 12. Higher values trade compression speed for compression ratio. Values above 12 are considered the same as 12. Recommended values are 1 for fast compression (default), and 9 for high compression. Speed/compression trade-off will vary depending on data to compress\. Decompression speed remains fast at all settings.

See also:

LZ4MBS.CompressHC(InputData as Ptr, Size as Integer, compressionLevel as Integer = 9) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses data in ptr.

Same as memoryblock version, but with ptr parameter, so you can pass ptr with size.
Works also for passing memoryblocks and a custom size.

See also:

LZ4MBS.CompressHC(InputData as string, compressionLevel as Integer = 9) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Compresses a string with high compression.

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns string on success.

Compression level, with # being any value from 1 to 12. Higher values trade compression speed for compression ratio. Values above 12 are considered the same as 12. Recommended values are 1 for fast compression (default), and 9 for high compression. Speed/compression trade-off will vary depending on data to compress\. Decompression speed remains fast at all settings.

See also:

LZ4MBS.Decompress(CompressedData as MemoryBlock, UncompressedSize as Integer = 0) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Decompresses a MemoryBlock.
Example
// some 10 million zeros will compress well
Dim m As New MemoryBlock(100000000)

// compress
Dim c As MemoryBlock = LZ4MBS.Compress(m)

// decompress
Dim d As MemoryBlock = LZ4MBS.Decompress(c)

// and check
If d.Size = m.size Then
MsgBox "Sizes match"
Else
MsgBox "Sizes don't match"
End If

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns memoryblock on success.

If UncompressedSize is zero, we try to determinate it.
If you know the size of decompressed data, please pass it to make function more efficient.

See also:

LZ4MBS.Decompress(CompressedData as Ptr, Size as Integer, UncompressedSize as Integer = 0) as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Decompresses data in ptr.

Same as memoryblock version, but with ptr parameter, so you can pass ptr with size.
Works also for passing memoryblocks and a custom size.

If UncompressedSize is zero, we try to determinate it.
If you know the size of decompressed data, please pass it to make function more efficient.

See also:

LZ4MBS.Decompress(CompressedData as string, UncompressedSize as Integer = 0) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Decompresses a String.
Example
Dim m As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor site amat."

// make sure encoding is set
m = ConvertEncoding(m, encodings.UTF8)

// compress
Dim c As String = LZ4MBS.Compress(m)

// decompress
Dim d As String = LZ4MBS.Decompress(c)

// set encoding after decompressing
d = DefineEncoding(d, encodings.UTF8)

// and check
If d = m Then
MsgBox "Text match"
Else
MsgBox "Text doesn't match"
End If

Raises exception on failure (OutOfMemoryException or UnsupportedOperationException) and returns memoryblock on success.

If UncompressedSize is zero, we try to determinate it.
If you know the size of decompressed data, please pass it to make function more efficient.

See also:

LZ4MBS.LibVersion as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 19.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Queries version of the LZ4 library.

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


The biggest plugin in space...