/// <summary>
/// Creates a new instance of <see cref="ZlibOutputStream"/> class.
/// </summary>
/// <param name="output">Underlying stream that will receive the processed data written to the <see cref="ZlibOutputStream"/> instance.</param>
/// <param name="mode">Specifies whether to compress or decompress data written to the stream.</param>
/// <param name="level">Compresion level. Only used when compressing data.</param>
public ZlibOutputStream(Stream output, CompressionMode mode, int level)
{
if (output == null)
{
throw new ArgumentNullException("input");
}
level = Math.Max(0, Math.Min(9, level));
_block = new byte[0x1000];
_output = output;
_compress = mode == CompressionMode.Compress;
_zstream = new ZStream();
if (_compress)
{
_zstream.deflateInit(level, false);
}
else
{
_zstream.inflateInit();
}
}