ComponentAce.Compression.Libs.ZLib.ZStream.deflateSetDictionary C# (CSharp) Method

deflateSetDictionary() public method

Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called immediately after deflateInit(int), before any call of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary).

The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary.

Depending on the size of the compression data structures selected by deflateInit(int), a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size in deflate. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front.

Upon return of this function, adler is set to the Adler32 value of the dictionary; the decompresser may later use this value to determine which dictionary has been used by the compressor. (The Adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.)

public deflateSetDictionary ( byte dictionary, int dictLength ) : int
dictionary byte A byte array - a dictionary.
dictLength int The length of the dictionary byte array
return int
		public int deflateSetDictionary(byte[] dictionary, int dictLength)
		{
			if (_dstate == null)
				return (int)ZLibResultCode.Z_STREAM_ERROR;
			return _dstate.deflateSetDictionary(this, dictionary, dictLength);
		}