本文整理汇总了C#中Ionic.Zlib.DeflateStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# DeflateStream.CopyTo方法的具体用法?C# DeflateStream.CopyTo怎么用?C# DeflateStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic.Zlib.DeflateStream
的用法示例。
在下文中一共展示了DeflateStream.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecryptAes128CbcWithGzip
private static byte[] DecryptAes128CbcWithGzip(byte[] data, byte[] key)
{
byte[] gzippedFile;
using (var cipher = new AesManaged { Mode = CipherMode.CBC, Key = key })
gzippedFile = cipher.CreateDecryptor().TransformFinalBlock(data, 0, data.Length).Skip(16).ToArray();
using (var inStream = new MemoryStream(gzippedFile))
using (var zipStream = new DeflateStream(inStream, CompressionMode.Decompress))
using (var outStream = new MemoryStream())
{
zipStream.CopyTo(outStream);
return outStream.ToArray();
}
}
示例2: Decode
/// <summary>
/// Decode the content
/// </summary>
/// <param name="data">Content to decode</param>
/// <returns>Decoded content</returns>
public byte[] Decode(byte[] data)
{
var output = new MemoryStream ();
var input = new MemoryStream (data);
/*
using (var stream = new System.IO.Compression.DeflateStream (input, System.IO.Compression.CompressionMode.Decompress))
stream.CopyTo (output);
return output.ToArray ();
*/
using (var stream = new DeflateStream (input, CompressionMode.Decompress))
stream.CopyTo (output);
return output.ToArray ();
}
示例3: DecompressTileBlock
public static void DecompressTileBlock(byte[] buffer, int bufferStart, int bufferLength)
{
using (MemoryStream memoryStream = new MemoryStream())
{
memoryStream.Write(buffer, bufferStart, bufferLength);
memoryStream.Position = 0L;
bool flag = memoryStream.ReadByte() != 0;
MemoryStream memoryStream3;
if (flag)
{
MemoryStream memoryStream2 = new MemoryStream();
using (DeflateStream deflateStream = new DeflateStream((Stream)memoryStream, CompressionMode.Decompress, CompressionLevel.BestCompression))
{
deflateStream.CopyTo(memoryStream2);
deflateStream.Close();
}
memoryStream3 = memoryStream2;
memoryStream3.Position = 0L;
}
else
{
memoryStream3 = memoryStream;
memoryStream3.Position = 1L;
}
using (BinaryReader binaryReader = new BinaryReader(memoryStream3))
{
int xStart = binaryReader.ReadInt32();
int yStart = binaryReader.ReadInt32();
short width = binaryReader.ReadInt16();
short height = binaryReader.ReadInt16();
NetMessage.DecompressTileBlock_Inner(binaryReader, xStart, yStart, (int)width, (int)height);
}
}
}
示例4: Decompress
private static byte[] Decompress(byte[] data)
{
// While a "real" PNG uses Zlib for the image data, the CgBI PNG image data is compressed with Deflate.
using (var inputStream = new MemoryStream(data, false))
{
using (var deflateStream = new DeflateStream(inputStream, CompressionMode.Decompress))
{
using (var newData = new MemoryStream())
{
deflateStream.CopyTo(newData);
return newData.ToArray();
}
}
}
}