IdeaBlade DevForce 2010 Help Reference
Inflate Method
See Also  Example Send Feedback
IdeaBlade.Core Assembly > Ionic.Zlib Namespace > ZlibCodec Class : Inflate Method



flush
The flush to use when inflating.
Inflate the data in the InputBuffer, placing the result in the OutputBuffer.

Syntax

Visual Basic (Declaration) 
Public Function Inflate( _
   ByVal flush As FlushType _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As ZlibCodec
Dim flush As FlushType
Dim value As Integer
 
value = instance.Inflate(flush)
C# 
public int Inflate( 
   FlushType flush
)
C++/CLI 
public:
int Inflate( 
   FlushType flush
) 

Parameters

flush
The flush to use when inflating.

Return Value

Z_OK if everything goes well.

Example

C#Copy 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 && 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();
}

Remarks

You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and AvailableBytesOut before calling this method.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.