本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# InflaterInputStream.Flush方法的具体用法?C# InflaterInputStream.Flush怎么用?C# InflaterInputStream.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
的用法示例。
在下文中一共展示了InflaterInputStream.Flush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeCompress
public static byte[] DeCompress( byte []b )
{
Stream s2 = new InflaterInputStream( new MemoryStream( b ) );
try
{
byte []dest = null;
int size = s2.Read( writeData, 0, writeData.Length);
if (size > 0)
{
dest = new byte[ size ];
Buffer.BlockCopy( writeData , 0, dest, 0, size );
}
s2.Flush();
s2.Close();
return dest;
}
catch(Exception e)
{
Console.WriteLine( e.Message );
return null;
}
}
示例2: DecompressZlib
public static byte[] DecompressZlib(byte[] input, int size)
{
byte[] result = new byte[size];
InflaterInputStream zipStream = new InflaterInputStream(new MemoryStream(input));
zipStream.Read(result, 0, size);
zipStream.Flush();
return result;
}
示例3: Decompress
public static byte[] Decompress(byte[] buffer, int offset, int count)
{
if (buffer == null)
throw new ArgumentNullException();
if (count < 0)
throw new FormatException();
if (offset + count > buffer.Length)
throw new IndexOutOfRangeException();
using (MemoryStream buffStream = new MemoryStream(buffer, offset, count))
{
InflaterInputStream zipStream;
uint magicStream = buffStream.ReadValueU32();
if (magicStream != magic && magicStream.Swap() != magic)
{
throw new InvalidDataException("found an invalid zlib block");
}
uint buffMaxSegmentSize = buffStream.ReadValueU32();
if (buffMaxSegmentSize != maxSegmentSize)
{
throw new FormatException();
}
uint totComprSize = buffStream.ReadValueU32();
uint totUncomprSize = buffStream.ReadValueU32();
byte[] outputBuffer = new byte[totUncomprSize];
int numOfSegm = (int)Math.Ceiling((double)totUncomprSize / (double)maxSegmentSize);
int headSegm = 16;
int dataSegm = headSegm + (numOfSegm * 8);
int buffOff = 0;
for (int i = 0; i < numOfSegm; i++)
{
buffStream.Seek(headSegm, SeekOrigin.Begin);
int comprSegm = buffStream.ReadValueS32();
int uncomprSegm = buffStream.ReadValueS32();
headSegm = (int)buffStream.Position;
buffStream.Seek(dataSegm, SeekOrigin.Begin);
//Console.WriteLine("compr size: {0}, uncompr size: {1}, data offset: 0x{2:X8}", comprSegm, uncomprSegm, dataSegm);
zipStream = new InflaterInputStream(buffStream);
zipStream.Read(outputBuffer, buffOff, uncomprSegm);
zipStream.Flush();
buffOff += uncomprSegm;
dataSegm += comprSegm;
}
buffStream.Close();
return outputBuffer;
}
}
示例4: UncompressBlock
private byte[] UncompressBlock(Stream s, uint CompSize, uint UnCompSize)
{
byte[] res = new byte[UnCompSize];
try
{
InflaterInputStream zipstream = new InflaterInputStream(s);
zipstream.Read(res, 0, (int)UnCompSize);
zipstream.Flush();
}
catch (Exception ex)
{
DebugLog.PrintLn("PCCPACKAGE::UNCOMPRESSBLOCK ERROR:\n" + ex.Message);
}
return res;
}