Sign in to follow this  
Quat

ZLIB Inflation C#

Recommended Posts

Quat    568
Hi,

I am tasked with reading a binary file. The documentation of the file format indicates that segments of the file may have ZLIB compression applied. For the parts that are not compressed, I am using BinaryReader which works fine. Basically, I want something ZLibBinaryReader that I can use to inflate the compressed data, but using API like ReadInt32, ReadSingle, etc.

Can anyone recommend a free open source library like this? I do not need to open entire compressed files, but I will have offset in file stream to start of compressed data, and want to start inflating the compressed data for some byteLength.

Share this post


Link to post
Share on other sites
YellowSnow    146
Since .NET 2.0 the framework comes with a class that you can use for this task: [url="http://msdn.microsoft.com/en-us/library/system.io.compression.deflatestream%28v=vs.80%29.aspx"]http://msdn.microsof...m(v=vs.80).aspx[/url]

Note however, that the stream written by zlib contains a header and a trailing checksum. DeflateStream only decompresses the raw data.
For more details see here: [url="http://tlzprgmr.wordpress.com/2010/03/17/net-deflatestreamzlib-compatibility/"]http://tlzprgmr.word...-compatibility/[/url] Edited by YellowSnow

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this