本文整理汇总了C#中Ionic.Zlib.ZlibStream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# ZlibStream.ReadByte方法的具体用法?C# ZlibStream.ReadByte怎么用?C# ZlibStream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zlib.ZlibStream
的用法示例。
在下文中一共展示了ZlibStream.ReadByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadCompressedID
public static byte ReadCompressedID(byte[] compressed)
{
using (MemoryStream input = new MemoryStream(compressed))
using (ZlibStream zin = new ZlibStream(input, CompressionMode.Decompress))
{
int val = zin.ReadByte();
if (val < 0)
throw new InvalidDataException();
return (byte)val;
}
}
示例2: Decompress
/// <summary>
/// Decompresses the specified data.
/// </summary>
/// <param name="data">The compressed byte array.</param>
/// <param name="pos">The starting position into the byte array.</param>
/// <param name="Length">The number of compressed bytes to decompress.</param>
/// <returns>An uncompressed byte array</returns>
public static byte[] Decompress(byte[] data, int pos, int Length)
{
byte[] compressedData = new byte[Length];
Array.Copy(data, pos + 50, compressedData, 0, Length);
ZlibStream inflaterInputStream = new ZlibStream(new MemoryStream(compressedData),CompressionMode.Decompress);
MemoryStream out1 = new MemoryStream();
int c;
try
{
while ((c = inflaterInputStream.ReadByte()) != -1)
out1.WriteByte((byte)c);
return out1.ToArray();
}
catch (IOException e)
{
throw new RecordFormatException(e.ToString());
}
finally
{
out1.Close();
if (inflaterInputStream != null)
{
inflaterInputStream.Close();
}
}
}