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


C# Inflater.Inflate方法代码示例

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


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

示例1: ReadCompressed

        public static void ReadCompressed(Stream s, List<string> classnames)
        {
            long start = s.Position;
            BinaryReader br = new BinaryReader(s);
            byte[] mem = new byte[(int)s.Length + 8];
            byte[] buf = new byte[3];
            s.Read(buf, 0, 3);
            s.Seek(start+4, SeekOrigin.Begin);
            int size = br.ReadInt32();
            s.Seek(start+8, SeekOrigin.Begin);
            s.Read(mem, 0, (int)s.Length);
            s.Close();
            br.Close();

            try
            {
                s = new MemoryStream(mem);
                if (Encoding.Default.GetString(buf) == "CWS")
                {
                    Inflater i = new Inflater();
                    i.SetInput(mem);
                    byte[] mem2 = new byte[size + 8];
                    i.Inflate(mem2, 8, size);
                    s = new MemoryStream(mem2);
                    mem = new byte[0];
                }

                s.Seek(0x15, SeekOrigin.Begin);
                br = new BinaryReader(s);
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    uint taglen = br.ReadUInt16();
                    uint len = taglen & 0x3f;
                    uint tag = (taglen - len) / 64;
                    if (len == 63)
                        len = br.ReadUInt32();
                    start = br.BaseStream.Position;

                    if (tag == 82)
                    {
                        FlashABC fabc = new FlashABC(br.BaseStream, len);
                        fabc.FindClasses(classnames);
                    }
                    br.BaseStream.Seek(start + len, SeekOrigin.Begin);
                }
                br.Close();
            }
            catch (Exception e)
            {
                Debug.Print(e.StackTrace);
                return;
            }
        }
开发者ID:TheCrazyT,项目名称:FlashABCRead,代码行数:53,代码来源:FlashRead.cs

示例2: Unzip

 public static byte[] Unzip(byte[] buffer)
 {
     Assembly callingAssembly = Assembly.GetCallingAssembly();
     Assembly executingAssembly = Assembly.GetExecutingAssembly();
     if ((callingAssembly != executingAssembly) && !PublicKeysMatch(executingAssembly, callingAssembly))
     {
         return null;
     }
     ZipStream stream = new ZipStream(buffer);
     byte[] buf = new byte[0];
     int num = stream.ReadInt();
     if (num == 0x4034b50)
     {
         short num2 = (short) stream.ReadShort();
         int num3 = stream.ReadShort();
         int num4 = stream.ReadShort();
         if (((num != 0x4034b50) || (num2 != 20)) || ((num3 != 0) || (num4 != 8)))
         {
             throw new FormatException("Wrong Header Signature");
         }
         stream.ReadInt();
         stream.ReadInt();
         stream.ReadInt();
         int num5 = stream.ReadInt();
         int count = stream.ReadShort();
         int num7 = stream.ReadShort();
         if (count > 0)
         {
             byte[] buffer3 = new byte[count];
             stream.Read(buffer3, 0, count);
         }
         if (num7 > 0)
         {
             byte[] buffer4 = new byte[num7];
             stream.Read(buffer4, 0, num7);
         }
         byte[] buffer5 = new byte[stream.Length - stream.Position];
         stream.Read(buffer5, 0, buffer5.Length);
         Inflater inflater = new Inflater(buffer5);
         buf = new byte[num5];
         inflater.Inflate(buf, 0, buf.Length);
         buffer5 = null;
     }
     else
     {
         int num8 = num >> 0x18;
         num -= num8 << 0x18;
         if (num == 0x7d7a7b)
         {
             switch (num8)
             {
                 case 1:
                 {
                     int num12;
                     int num9 = stream.ReadInt();
                     buf = new byte[num9];
                     for (int i = 0; i < num9; i += num12)
                     {
                         int num11 = stream.ReadInt();
                         num12 = stream.ReadInt();
                         byte[] buffer6 = new byte[num11];
                         stream.Read(buffer6, 0, buffer6.Length);
                         new Inflater(buffer6).Inflate(buf, i, num12);
                     }
                     break;
                 }
                 case 2:
                 {
                     byte[] buffer7 = new byte[] { 0x94, 0xad, 0xc3, 0x85, 0xa5, 0x2a, 0xbd, 9 };
                     byte[] buffer8 = new byte[] { 0xbf, 0x45, 3, 0x1a, 0x41, 80, 14, 0xbf };
                     using (ICryptoTransform transform = GetDesTransform(buffer7, buffer8, true))
                     {
                         buf = Unzip(transform.TransformFinalBlock(buffer, 4, buffer.Length - 4));
                     }
                     break;
                 }
             }
             if (num8 != 3)
             {
                 goto Label_026B;
             }
             byte[] key = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
             byte[] iv = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
             using (ICryptoTransform transform2 = GetAesTransform(key, iv, true))
             {
                 buf = Unzip(transform2.TransformFinalBlock(buffer, 4, buffer.Length - 4));
                 goto Label_026B;
             }
         }
         throw new FormatException("Unknown Header");
     }
 Label_026B:
     stream.Close();
     stream = null;
     return buf;
 }
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:96,代码来源:SimpleZip.cs

示例3: FlashReadFile

        public FlashReadFile(string file)
        {
            FileStream fs = new FileStream(file, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            byte[] mem = new byte[(int)fs.Length + 8];
            byte[] buf = new byte[3];
            fs.Read(buf, 0, 3);
            fs.Seek(4, SeekOrigin.Begin);
            int size = br.ReadInt32();
            fs.Seek(8, SeekOrigin.Begin);
            fs.Read(mem, 0, (int)fs.Length);
            fs.Close();
            br.Close();

            s = new MemoryStream(mem);
            if (Encoding.Default.GetString(buf) == "CWS")
            {
                Inflater i = new Inflater();
                i.SetInput(mem);
                byte[] mem2 = new byte[size + 8];
                i.Inflate(mem2, 8, size);
                s = new MemoryStream(mem2);
                mem = new byte[0];
            }
            s.Seek(0x15, SeekOrigin.Begin);
            br = new BinaryReader(s);
            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                uint taglen = br.ReadUInt16();
                uint len = taglen & 0x3f;
                uint tag = (taglen - len) / 64;
                if (len == 63)
                    len = br.ReadUInt32();
                long start = br.BaseStream.Position;

                if (tag == 82)
                {
                    FlashABC fabc = new FlashABC(br.BaseStream, len);
                    List<string> classnames = new List<string>();
                    classnames.Add("cPlayerData");
                    fabc.FindClasses(classnames);
                }
                //Debug.Print("{0} {1}", tag, len+2);
                br.BaseStream.Seek(start + len, SeekOrigin.Begin);
            }
            fClass.InitClasses();
            br.Close();
        }
开发者ID:TheCrazyT,项目名称:FlashABCRead,代码行数:48,代码来源:FlashRead.cs

示例4: CheckReader

        void CheckReader()
        {
            if (reader == null) {
                if (!record.IsCompressed)
                    throw new InvalidOperationException();
                int compressedSize = checked((int)record.Size);
                int uncompressedSize = checked((int)compressedReader.ReadUInt32());

                byte[] compressedData = new byte[compressedSize];
                byte[] uncompressedData = new byte[uncompressedSize];

                int compressedRead = compressedReader.Read(compressedData, 0, compressedSize);
                Inflater inflater = new Inflater();
                inflater.SetInput(compressedData);
                int uncompressedRead = inflater.Inflate(uncompressedData, 0, uncompressedSize);
                reader = new BinaryReader(new MemoryStream(uncompressedData, false));
                endOffset = uncompressedSize;
            }
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:19,代码来源:RecordReader.cs

示例5: Inflate

    static int Inflate(Inflater inf, byte [] src, byte [] dest)
    {
        int offset, length, remain;

        inf.Reset ();
        inf.SetInput (src);

        offset = 0;
        while (!inf.IsNeedingInput) {
            remain = Math.Min (dest.Length - offset, BlockSize);
            if (remain == 0)
                break;

            length = inf.Inflate (dest, offset, remain);
            offset += length;
        }

        return inf.TotalOut;
    }
开发者ID:AveProjVstm,项目名称:MonoVstm,代码行数:19,代码来源:zipmark.cs

示例6: Read

        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            // Cache it.
            fVersion = mgr.Version;

            // Cyan stores these values, but we're just going to
            //     save the stream and have fun with it...
            fBuffer = new byte[s.ReadInt()];
            Compression type = (Compression)s.ReadByte();
            uint len = s.ReadUInt();

            if (type == Compression.kZlib) {
                short streamType = s.ReadShort();
                byte[] buf = s.ReadBytes((int)len - 2);

                // Create a zlib-compatible inflator
                // Note: incoming has no zlib header/footer
                //       System.IO.Compression sucks.
                Inflater zlib = new Inflater(true);
                zlib.Inflate(buf);

                Buffer.BlockCopy(BitConverter.GetBytes(streamType), 0, fBuffer, 0, 2);
                Buffer.BlockCopy(buf, 0, fBuffer, 2, buf.Length);
            } else
                fBuffer = s.ReadBytes((int)len);
        }
开发者ID:branan,项目名称:PlasmaDotNet,代码行数:28,代码来源:NetMsgStream.cs

示例7: CheckSwf

        private bool CheckSwf(bool is_comp)
        {
            this.format = MediaFormat.SWF;
            this.reader = new BinaryReader(this.stream);

            if (is_comp) {
                int size = -1;

                this.reader.BaseStream.Position = 4; // Skip head
                size = Convert.ToInt32(this.reader.ReadUInt32());

                // Read swf head
                byte[] uncompressed = new byte[size];
                this.reader.BaseStream.Position = 0;
                this.reader.Read(uncompressed, 0, 8);

                // Read compressed data
                byte[] compressed = this.reader.ReadBytes(size);
                this.stream.Close(); // Close the old stream

                // Uncompress
                Inflater zipInflator = new Inflater();
                zipInflator.SetInput(compressed);
                zipInflator.Inflate(uncompressed, 8, size - 8);

                // Setup new uncompressed reader
                this.reader = new BinaryReader(new MemoryStream(uncompressed));
                this.reader.BaseStream.Position = 0;
            }

            // Skip header signature/version etc etc
            this.reader.BaseStream.Position = 8;

            // Read rect
            uint bits = ReadUBits(5);
            ReadSBits(bits); // Read xmin
            this.width = ReadSBits(bits) / 20; // Read xmax
            ReadSBits(bits); // Read ymin
            this.height = ReadSBits(bits) / 20; // Read ymax

            return true;
        }
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:42,代码来源:MediaInfo.cs

示例8: decompress

 private void decompress(AnyObjectId id, Inflater inf, int p)
 {
     try
     {
         while (!inf.IsFinished)
             p += inf.Inflate(bytes, p, objectSize - p);
     }
     catch (IOException dfe)
     {
         CorruptObjectException coe;
         coe = new CorruptObjectException(id, "bad stream", dfe);
         throw coe;
     }
     if (p != objectSize)
         throw new CorruptObjectException(id, "incorrect Length");
 }
开发者ID:ArildF,项目名称:GitSharp,代码行数:16,代码来源:UnpackedObjectLoader.cs

示例9: Decompress

        public static string Decompress(String str)
        {
            // Initialize decompressor.
            byte[] compressedBytes = Convert.FromBase64String(str);
            Inflater decompressor = new Inflater();
            decompressor.SetInput(compressedBytes); // Give the decompressor the
            // data to decompress.

            byte[] ret = null;

            using (MemoryStream memStream = new MemoryStream(compressedBytes.Length))
            {
                // Decompress the data
                byte[] buf = new byte[compressedBytes.Length + 100];
                while (!decompressor.IsFinished)
                {
                    memStream.Write(buf, 0, decompressor.Inflate(buf));
                }

                memStream.Close();
                ret = memStream.ToArray();
            }

            return ASCIIEncoding.UTF8.GetString(ret);
        }
开发者ID:harryho,项目名称:demo-fx-trading-platform-prototype,代码行数:25,代码来源:Connector.cs


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