当前位置: 首页>>代码示例>>C#>>正文


C# ZlibStream.CopyTo方法代码示例

本文整理汇总了C#中Ionic.Zlib.ZlibStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# ZlibStream.CopyTo方法的具体用法?C# ZlibStream.CopyTo怎么用?C# ZlibStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ionic.Zlib.ZlibStream的用法示例。


在下文中一共展示了ZlibStream.CopyTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: uncompress

        public void uncompress(Stream inStream, Stream outStream)
        {

            ZlibStream compressionStream = new ZlibStream(inStream, CompressionMode.Decompress, true);

            compressionStream.CopyTo(outStream);

        }
开发者ID:superkaka,项目名称:mycsharp,代码行数:8,代码来源:ZlibCompresser.cs

示例2: DecompressDeflate

 public static byte[] DecompressDeflate(byte[] InData)
 {
     using (MemoryStream ms = new MemoryStream(InData))
     {
         using (ZlibStream zs = new ZlibStream(ms, CompressionMode.Decompress))
         {
             using (MemoryStream output = new MemoryStream())
             {
                 zs.CopyTo(output);
                 return output.ToArray();
             }
         }
     }
 }
开发者ID:Nihlus,项目名称:libwarcraft,代码行数:14,代码来源:Compression.cs

示例3: Decompress

 protected OffsettableStream Decompress(Stream stream, long offset, int allocsize)
 {
     stream.Seek(offset, SeekOrigin.Begin);
     using (ZlibStream zstream = new ZlibStream(stream, CompressionMode.Decompress, true))
     {
         OffsettableMemoryStream outstrm = new OffsettableMemoryStream(allocsize);
         zstream.CopyTo(outstrm);
         outstrm.Position = 0;
         TotalSize = (int)zstream.TotalOut;
         CompressedSize = (int)zstream.TotalIn;
         this.DataLength = TotalSize;
         return outstrm;
     }
 }
开发者ID:klightspeed,项目名称:RS5-Extractor,代码行数:14,代码来源:SubArray.cs

示例4: CopyDecompressed

        public static void CopyDecompressed(string inputPath, string outputPath)
        {
            if (inputPath.ToLowerInvariant() == outputPath.ToLowerInvariant())
            {
                throw new Exception("The input and output files must be different.");
            }

            using (var swfStream = new FileStream(inputPath, FileMode.Open, FileAccess.Read))
            {
                const int headerSize = 8;

                var read = 0;
                var header = new byte[headerSize];
                do
                {
                    read = swfStream.Read(header, read, headerSize - read);
                } while (read < headerSize);
                switch (header[0])
                {
                    case 0x46:
                        // already uncompressed - just copy the file
                        using (var outStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
                        {
                            outStream.Write(header, 0, headerSize);
                            swfStream.CopyTo(outStream);
                        }
                        break;
                    case 0x43:
                        using (var outStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
                        {
                            header[0] = 0x46;
                            outStream.Write(header, 0, headerSize);
                            using (var decompressed = new ZlibStream(swfStream, CompressionMode.Decompress))
                            {
                                decompressed.CopyTo(outStream);
                            }
                        }
                        break;
                    case 0x5A:
                        throw new Exception("LZMA compression is not supported (yet).");
                    default:
                        throw new Exception(string.Format("Unexpected compression type: 0x{0:x2}", header[0]));
                }
            }
        }
开发者ID:bungeemonkee,项目名称:InspectorSwfTime,代码行数:45,代码来源:SwfFileUtility.cs

示例5: Decompress

        private void Decompress(Object state)
        {
            Chunk c = (Chunk)state;

            if (c.CompressionType == 1) //GZip
            {
                GZipStream decompress = new GZipStream(new MemoryStream(c.RawData), CompressionMode.Decompress);
                MemoryStream mem = new MemoryStream();
                decompress.CopyTo(mem);
                mem.Seek(0, SeekOrigin.Begin);
                c.Root = new TAG_Compound(mem);
            }
            else if (c.CompressionType == 2) //Zlib
            {
                ZlibStream decompress = new ZlibStream(new MemoryStream(c.RawData), CompressionMode.Decompress);
                MemoryStream mem = new MemoryStream();
                decompress.CopyTo(mem);
                mem.Seek(0, SeekOrigin.Begin);
                c.Root = new TAG_Compound(mem);
            }
            else
            {
                throw new Exception("Unrecognized compression type");
            }

            if (Interlocked.Decrement(ref taskCount) == 0)
                signal.Set();
        }
开发者ID:mblaine,项目名称:BiomePainter,代码行数:28,代码来源:RegionFile.cs

示例6: DecodeSubtitle

 private void DecodeSubtitle(int subtitleId, string ivBase64, string dataBase64, ref CrunchySubtitleInfo si)
 {
     byte[] key = GenerateKey(subtitleId).Concat(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }).ToArray();
     byte[] iv = Convert.FromBase64String(ivBase64);
     byte[] data = Convert.FromBase64String(dataBase64);
     AesManaged mng = new AesManaged();
     mng.Mode = CipherMode.CBC;
     mng.Padding = PaddingMode.None;
     ICryptoTransform tr = mng.CreateDecryptor(key, iv);
     byte[] kk = tr.TransformFinalBlock(data, 0, data.Length);
     MemoryStream ms = new MemoryStream();
     ZlibStream stream = new ZlibStream(new MemoryStream(kk), Ionic.Zlib.CompressionMode.Decompress);
     stream.CopyTo(ms);
     ms.Position = 0;
     XmlSerializer serializer = new XmlSerializer(typeof(SubtitleScript));
     SubtitleScript script = (SubtitleScript)serializer.Deserialize(ms);
     si.Title = script.Title;
     si.Ass = script.ToAss();
 }
开发者ID:maxpiva,项目名称:AnimeOfflineDownloader,代码行数:19,代码来源:Crunchy.cs

示例7: GetText

 private string GetText()
 {
     var r = new StringBuilder(numTextPages);
     for (int i = 1; i <= numTextPages; i++)
     {
         byte[] encryptedSection = pdbReader.GetSection(i);
         byte[] decryptedSection = contentDecryptor.TransformFinalBlock(encryptedSection, 0, encryptedSection.Length);
         byte[] decompressedSection;
         using (var inStream = new MemoryStream(decryptedSection))
         using (var zipStream = new ZlibStream(inStream, CompressionMode.Decompress))
         using (var outStream = new MemoryStream())
         {
             zipStream.CopyTo(outStream);
             decompressedSection = outStream.ToArray();
         }
         string text = Encoding.GetEncoding(1252).GetString(decompressedSection);
         r.Append(text);
     }
     return r.ToString();
 }
开发者ID:13xforever,项目名称:DeDRM,代码行数:20,代码来源:EReaderProcessor.cs

示例8: Read

        //http://www.minecraftwiki.net/wiki/Region_file_format
        public void Read(String path)
        {
            Chunks = new Chunk[32, 32];
            Match m = Regex.Match(path, @"r\.(-?\d+)\.(-?\d+)\.mc[ar]");
            Coords.X = int.Parse(m.Groups[1].Value);
            Coords.Z = int.Parse(m.Groups[2].Value);

            byte[] header = new byte[8192];

            using (BinaryReader file = new BinaryReader(File.Open(path, FileMode.Open)))
            {
                file.Read(header, 0, 8192);

                for (int chunkZ = 0; chunkZ < 32; chunkZ++)
                {
                    for (int chunkX = 0; chunkX < 32; chunkX++)
                    {
                        Chunk c = new Chunk();
                        c.Coords.X = Coords.X;
                        c.Coords.Z = Coords.Z;
                        c.Coords.RegiontoChunk();
                        c.Coords.Add(chunkX, chunkZ);

                        int i = 4 * (chunkX + chunkZ * 32);

                        byte[] temp = new byte[4];
                        temp[0] = 0;
                        Array.Copy(header, i, temp, 1, 3);
                        if (BitConverter.IsLittleEndian)
                            Array.Reverse(temp);
                        long offset = ((long)BitConverter.ToInt32(temp, 0)) * 4096;
                        int length = header[i + 3] * 4096;

                        temp = new byte[4];
                        Array.Copy(header, i + 4096, temp, 0, 4);
                        if (BitConverter.IsLittleEndian)
                            Array.Reverse(temp);
                        c.Timestamp = BitConverter.ToInt32(temp, 0);

                        if (offset == 0 && length == 0)
                        {
                            Chunks[chunkX, chunkZ] = c;
                            continue;
                        }

                        file.BaseStream.Seek(offset, SeekOrigin.Begin);

                        temp = new byte[4];
                        file.Read(temp, 0, 4);
                        if (BitConverter.IsLittleEndian)
                            Array.Reverse(temp);
                        int exactLength = BitConverter.ToInt32(temp, 0);

                        c.CompressionType = file.ReadByte();
                        if (c.CompressionType == 1) //GZip
                        {
                            c.RawData = new byte[exactLength - 1];
                            file.Read(c.RawData, 0, exactLength - 1);

                            GZipStream decompress = new GZipStream(new MemoryStream(c.RawData), CompressionMode.Decompress);
                            MemoryStream mem = new MemoryStream();
                            decompress.CopyTo(mem);
                            mem.Seek(0, SeekOrigin.Begin);
                            c.Root = new TAG_Compound(mem);
                        }
                        else if (c.CompressionType == 2) //Zlib
                        {
                            c.RawData = new byte[exactLength - 1];
                            file.Read(c.RawData, 0, exactLength - 1);

                            ZlibStream decompress = new ZlibStream(new MemoryStream(c.RawData), CompressionMode.Decompress);
                            MemoryStream mem = new MemoryStream();
                            decompress.CopyTo(mem);
                            mem.Seek(0, SeekOrigin.Begin);
                            c.Root = new TAG_Compound(mem);
                        }
                        else
                        {
                            throw new Exception("Unrecognized compression type");
                        }

                        Chunks[chunkX, chunkZ] = c;
                    }
                }

                file.Close();
            }
        }
开发者ID:mblaine,项目名称:NbtViewer,代码行数:89,代码来源:RegionFile.cs

示例9: DecompressPacket

        private byte[] DecompressPacket(SOEClient sender, byte[] packet)
        {
            // Compressable?
            if (!sender.IsCompressable())
            {
                return packet;
            }

            // Remove the OpCode and compression flag
            byte[] data = new byte[packet.Length - 3];
            for (int i = 3; i < packet.Length; i++)
            {
                data[i - 3] = packet[i];
            }

            byte[] decompressedData = data;

            // Decompress the old packet..
            MemoryStream dataStream = new MemoryStream(data);
            MemoryStream decompressed = new MemoryStream();

            if (packet[2] == 0x01)
            {
                using (ZlibStream zlibStream = new ZlibStream(dataStream, CompressionMode.Decompress))
                {
                    zlibStream.CopyTo(decompressed);
                }

                // Reconstruct the packet..
                decompressedData = decompressed.ToArray();
            }

            // Reconstruct the packet..
            byte[] newPacket = new byte[decompressedData.Length + 2];

            // OpCode
            int place = 0;
            for (int i = 0; i < 2; i++)
            {
                newPacket[place] = packet[i];
                place++;
            }

            // Data
            for (int i = 0; i < decompressedData.Length; i++)
            {
                newPacket[place] = decompressedData[i];
                place++;
            }

            // And.. return!
            return newPacket;
        }
开发者ID:Joshsora,项目名称:LibSOE,代码行数:53,代码来源:SOEProtocol.cs

示例10: Decompress

 private byte[] Decompress(byte[] bytes)
 {
     if (bytes[0] == 0x1f && bytes[1] == 0x8b)
     {
         using (MemoryStream memory = new MemoryStream(bytes))
         {
             using (GZipStream gzip = new GZipStream(memory, CompressionMode.Decompress))
             {
                 using (MemoryStream result = new MemoryStream())
                 {
                     gzip.CopyTo(result);
                     return result.ToArray();
                 }
             }
         }
     }
     if (bytes[0] == 0x78 && bytes[1] == 0x9c)
     {
         using (MemoryStream memory = new MemoryStream(bytes))
         {
             using (ZlibStream deflate = new ZlibStream(memory, CompressionMode.Decompress))
             {
                 using (MemoryStream result = new MemoryStream())
                 {
                     deflate.CopyTo(result);
                     return result.ToArray();
                 }
             }
         }
     }
     return bytes;
 }
开发者ID:jbrwn,项目名称:tc,代码行数:32,代码来源:MapnikVectorTileProvider.cs


注:本文中的Ionic.Zlib.ZlibStream.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。