/// <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(); } }
/// <summary> /// Creates a new instance of <see cref="ZlibInputStream"/> class. /// </summary> /// <param name="input">Underlying stream from which to read the data to process.</param> /// <param name="mode">Specifies whether to compress or decompress data read from the stream.</param> /// <param name="level">Compression level. Only used when compressing data.</param> public ZlibInputStream(Stream input, CompressionMode mode, int level) { if (input == null) throw new ArgumentNullException("input"); level = Math.Max(0, Math.Min(9, level)); _buffer = new byte[0x1000]; _input = input; _compress = mode == CompressionMode.Compress; _zstream = new ZStream(); if (_compress) _zstream.deflateInit(level, false); else _zstream.inflateInit(); }