Ionic Zip Library v1.9.1.6
Inflate Method (flush)
Reference ► Ionic.Zlib ► ZlibCodec ► Inflate(FlushType)
Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
Declaration Syntax
Parameters
- flush (FlushType)
- The flush to use when inflating.
Return Value
Z_OK if everything goes well.
Remarks
You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and
AvailableBytesOut before calling this method.
Examples
CopyC#
private void InflateBuffer() { int bufferSize = 1024; byte[] buffer = new byte[bufferSize]; ZlibCodec decompressor = new ZlibCodec(); Console.WriteLine("\n============================================"); Console.WriteLine("Size of Buffer to Inflate: {0} bytes.", CompressedBytes.Length); MemoryStream ms = new MemoryStream(DecompressedBytes); int rc = decompressor.InitializeInflate(); decompressor.InputBuffer = CompressedBytes; decompressor.NextIn = 0; decompressor.AvailableBytesIn = CompressedBytes.Length; decompressor.OutputBuffer = buffer; // pass 1: inflate do { decompressor.NextOut = 0; decompressor.AvailableBytesOut = buffer.Length; rc = decompressor.Inflate(FlushType.None); if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) throw new Exception("inflating: " + decompressor.Message); ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut); } while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0); // pass 2: finish and flush do { decompressor.NextOut = 0; decompressor.AvailableBytesOut = buffer.Length; rc = decompressor.Inflate(FlushType.Finish); if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK) throw new Exception("inflating: " + decompressor.Message); if (buffer.Length - decompressor.AvailableBytesOut > 0) ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut); } while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0); decompressor.EndInflate(); }