Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Compression Settings

RadZipLibrary allows you compress and decompress data in your application seamlessly. There are different settings that can be used for compression and this article discusses all of them.

Deflate Settings

Deflate settings are used for compressing data using a combination of the LZ77 algorithm and Huffman coding.

You can find more information on the Deflate data compression algorithm here.

The DeflateSettings class exposes some configurable parameters:

  • CompressionLevel: Property of type CompressionLevel representing the level of compression of the algorithm.

  • HeaderType: Represents the compression stream header type. The possible values are None and ZLib.

Example 1 demonstrates how to create DeflateSettings.

Example 1: Create DeflateSettings

DeflateSettings compressionSettings = new DeflateSettings(); 
compressionSettings.CompressionLevel = CompressionLevel.Best; 
compressionSettings.HeaderType = CompressedStreamHeader.ZLib; 
Dim compressionSettings As New DeflateSettings() 
compressionSettings.CompressionLevel = CompressionLevel.Best 
compressionSettings.HeaderType = CompressedStreamHeader.ZLib 

LZMA Settings

LZMA settings are used for compressing your data using Lempel-Ziv-Markov chain algorithm (LZMA).

You can read more about LZMA here.

The configurable parameters of the LzmaSettings class are as follows:

  • DictionarySize: The size of the used dictionary. Allowed values are in the range [0 – 27] and the default value is 23 (8MB).

  • PositionStateBits: The number of position state bits. Allowed values are in the range [0 – 4]; the default value is 2.

  • LiteralContextBits: The number of literal context bits. Allowed values are in the range [0 – 4]; the default value is 3.

  • LiteralPositionBits: The number of literal position bits. Allowed values are in the range [0 – 4]; the default value is 3.

  • FastBytes: The number of fast bytes. Allowed values are in the range [5 – 273]; the default value is 32.

  • MatchFinderType: The type of the match finder. Allowed values are BT2(match finder that uses two bytes for the hash) and BT4(uses four bytes for the hash).

Example 2: Create LzmaSettings

LzmaSettings compressionSettings = new LzmaSettings(); 
compressionSettings.DictionarySize = 23; 
compressionSettings.FastBytes = 32; 
compressionSettings.LiteralContextBits = 3; 
compressionSettings.LiteralPositionBits = 3; 
compressionSettings.MatchFinderType = LzmaMatchFinderType.BT4; 
compressionSettings.PositionStateBits = 2; 
Dim compressionSettings As New LzmaSettings() 
compressionSettings.DictionarySize = 23 
compressionSettings.FastBytes = 32 
compressionSettings.LiteralContextBits = 3 
compressionSettings.LiteralPositionBits = 3 
compressionSettings.MatchFinderType = LzmaMatchFinderType.BT4 
compressionSettings.PositionStateBits = 2 

Store Settings

Store settings are used to just store the data using no compression.

Example 3: Create StoreSettings

StoreSettings compressionSettings = new StoreSettings(); 
Dim compressionSettings As New StoreSettings() 

See Also

In this article