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



Initialize the ZlibCodec for deflation operation.

Syntax

Visual Basic (Declaration) 
Public Overloads Function InitializeDeflate() As Integer
Visual Basic (Usage)Copy Code
Dim instance As ZlibCodec
Dim value As Integer
 
value = instance.InitializeDeflate()
C# 
public int InitializeDeflate()
C++/CLI 
public:
int InitializeDeflate(); 

Return Value

Z_OK if all goes well. You generally don't need to check the return code.

Example

C#Copy Code
int bufferSize = 40000;
byte[] CompressedBytes = new byte[bufferSize];
byte[] DecompressedBytes = new byte[bufferSize];
             
ZlibCodec compressor = new ZlibCodec();
             
compressor.InitializeDeflate(CompressionLevel.Default);
             
compressor.InputBuffer = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToCompress);
compressor.NextIn = 0;
compressor.AvailableBytesIn = compressor.InputBuffer.Length;
             
compressor.OutputBuffer = CompressedBytes;
compressor.NextOut = 0;
compressor.AvailableBytesOut = CompressedBytes.Length;
             
while (compressor.TotalBytesIn != TextToCompress.Length && compressor.TotalBytesOut < bufferSize)
{
  compressor.Deflate(FlushType.None);
}
             
while (true)
{
  int rc= compressor.Deflate(FlushType.Finish);
  if (rc == ZlibConstants.Z_STREAM_END) break;
}
             
compressor.EndDeflate();

Remarks

The codec will use the MAX window bits and the default level of compression.

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.