示例#1
0
 public int deflateSetDictionary(byte[] dictionary, int dictLength)
 {
     if (dstate == null)
     {
         return(Z_STREAM_ERROR);
     }
     return(dstate.deflateSetDictionary(this, dictionary, dictLength));
 }
示例#2
0
 /// <summary>
 /// Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called
 /// immediately after <see cref="DeflateInit(int)" />, before any call of <see cref="deflate" />. The compressor and decompressor must use
 /// exactly the same dictionary (see <see cref="inflateSetDictionary" />).
 /// </summary>
 /// <param name="dictionary">A byte array - a dictionary.</param>
 /// <param name="dictLength">The length of the dictionary byte array</param>
 /// <remarks>
 /// <para>
 /// 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.
 /// </para>
 /// <para>Depending on the size of the compression data structures selected by <see cref="DeflateInit(int)" />, a part of the dictionary may
 /// in effect be discarded, for example if the dictionary is larger than the window size in <see cref="deflate" />. Thus the strings most likely
 /// to be useful should be put at the end of the dictionary, not at the front.</para>
 /// <para>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.)</para>
 /// </remarks>
 /// <returns>
 /// deflateSetDictionary returns <see cref="ZLibResultCode.Z_OK" /> if success, or <see cref="ZLibResultCode.Z_STREAM_ERROR" /> if a parameter
 /// is invalid (such as <c>null</c> dictionary) or the stream state is inconsistent (for example if <see cref="deflate" /> has already been
 /// called for this stream or if the compression method is bsort). <see cref="deflateSetDictionary" /> does not perform any compression:
 /// this will be done by <see cref="deflate" />.
 /// </returns>
 public int deflateSetDictionary(byte[] dictionary, int dictLength)
 {
     if (_dstate == null)
     {
         return((int)ZLibResultCode.Z_STREAM_ERROR);
     }
     return(_dstate.deflateSetDictionary(this, dictionary, dictLength));
 }