# Compression Settings

**RadZipLibrary** allows you to compress and decompress data in your application. There are different settings that you can use for compression. This article discusses all of them.

## Deflate Settings

Deflate settings compress data using a combination of the LZ77 algorithm and Huffman coding.

> tip You can find more information on the Deflate data compression algorithm [in Wikipedia](https://en.wikipedia.org/wiki/DEFLATE).

The `DeflateSettings` class exposes the following configurable parameters:

* `CompressionLevel`—Property of type `CompressionLevel` that represents the level of compression of the algorithm.

* `HeaderType`—Represents the compression stream header type. The possible values are `None` and `ZLib`.

**Example 1: Create DeflateSettings**

```C#
DeflateSettings compressionSettings = new DeflateSettings();
compressionSettings.CompressionLevel = CompressionLevel.Best;
compressionSettings.HeaderType = CompressedStreamHeader.ZLib;
```

## LZMA Settings

LZMA settings compress data using the Lempel-Ziv-Markov chain algorithm (LZMA).

> tip You can read more about LZMA [in Wikipedia](https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm).

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 (8 MB).

* `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**

```C#
LzmaSettings compressionSettings = 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 store the data without applying any compression.

**Example 3: Create StoreSettings**

```C#
StoreSettings compressionSettings = new StoreSettings();
```

## See Also

* [Compressing a Stream](https://www.telerik.com/document-processing-libraries/documentation/libraries/radziplibrary/features/compress-stream)
