Пример #1
0
 /// <summary>
 /// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
 /// </summary>
 /// <remarks>
 /// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and
 /// AvailableBytesOut  before calling this method.
 /// </remarks>
 /// <example>
 /// <code>
 /// 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 &amp;&amp; rc != ZlibConstants.Z_STREAM_END)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 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 &amp;&amp; rc != ZlibConstants.Z_OK)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         if (buffer.Length - decompressor.AvailableBytesOut &gt; 0)
 ///             ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);
 ///
 ///     decompressor.EndInflate();
 /// }
 ///
 /// </code>
 /// </example>
 /// <param name="flush">The flush to use when inflating.</param>
 /// <returns>Z_OK if everything goes well.</returns>
 public int Inflate(FlushType flush)
 {
     if (istate == null)
     {
         throw new ZlibException("No Inflate State!");
     }
     return(istate.Inflate(flush));
 }
Пример #2
0
 /// <summary>
 /// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
 /// </summary>
 /// <remarks>
 /// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and
 /// AvailableBytesOut  before calling this method.
 /// </remarks>
 /// <example>
 /// <code>
 /// 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(ZlibConstants.Z_NO_FLUSH);
 ///
 ///         if (rc != ZlibConstants.Z_OK &amp;&amp; rc != ZlibConstants.Z_STREAM_END)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);
 ///
 ///     // pass 2: finish and flush
 ///     do
 ///     {
 ///         decompressor.NextOut = 0;
 ///         decompressor.AvailableBytesOut = buffer.Length;
 ///         rc = decompressor.Inflate(ZlibConstants.Z_FINISH);
 ///
 ///         if (rc != ZlibConstants.Z_STREAM_END &amp;&amp; rc != ZlibConstants.Z_OK)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         if (buffer.Length - decompressor.AvailableBytesOut &gt; 0)
 ///             ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);
 ///
 ///     decompressor.EndInflate();
 /// }
 ///
 /// </code>
 /// </example>
 /// <param name="f">I think you want to set this to Z_NO_FLUSH.</param>
 /// <returns>Z_OK if everything goes well.</returns>
 public int Inflate(int f)
 {
     if (istate == null)
     {
         throw new ZlibException("No Inflate State!");
     }
     return(istate.Inflate(this, f));
 }
Пример #3
0
        public int Inflate()
        {
            if (Istate == null)
            {
                throw new ZlibException("No Inflate State!");
            }

            return(Istate.Inflate());
        }
Пример #4
0
 /// <summary>
 /// 压缩 InputBuffer 的数据, 存放到 OutputBuffer。
 /// </summary>
 /// <remarks>
 /// 必须先设置 InputBuffer , OutputBuffer, NextIn , NextOut , AvailableBytesIn 和 AvailableBytesOut 。
 /// </remarks>
 /// <example>
 /// <code>
 /// 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 != ZlibState.Success &amp;&amp; rc != ZlibState.StreamEnd)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);
 ///
 ///     // pass 2: finish and flush
 ///     do
 ///     {
 ///         decompressor.NextOut = 0;
 ///         decompressor.AvailableBytesOut = buffer.Length;
 ///         rc = decompressor.Inflate(FlushType.Finish);
 ///
 ///         if (rc != ZlibState.StreamEnd &amp;&amp; rc != ZlibState.Success)
 ///             throw new Exception("inflating: " + decompressor.Message);
 ///
 ///         if (buffer.Length - decompressor.AvailableBytesOut &gt; 0)
 ///             ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
 ///     }
 ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);
 ///
 ///     decompressor.EndInflate();
 /// }
 ///
 /// </code>
 /// </example>
 /// <param name="flush">缓存类型。</param>
 /// <returns>如果正常返回 ZlibState.Success 。</returns>
 public ZlibState Inflate(FlushType flush)
 {
     Thrower.ThrowZlibExceptionIf(IState == null, "没有初始化 Inflate 状态。");
     return(IState.Inflate(flush));
 }