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


C# Inflater类代码示例

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


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

示例1: SetInflaterInput

 /// <summary>
 ///   Call <see cref="Inflater.SetInput(byte[], int, int)" /> passing the current clear text buffer contents.
 /// </summary>
 /// <param name="inflater">The inflater to set input for.</param>
 public void SetInflaterInput(Inflater inflater)
 {
   if (available > 0)
   {
     inflater.SetInput(clearText, clearTextLength - available, available);
     available = 0;
   }
 }
开发者ID:IntegralLee,项目名称:fomm,代码行数:12,代码来源:InflaterInputStream.cs

示例2: Read

        public NbtNode Read(int x, int z)
        {
            lock (this)
            {
                MoveToHeaderPosition(x, z);

                var index = _filePointer.ReadInt32();
                if (index == 0) return null; // Not yet generated

                int usedSectors = index & 0xFF;
                int sectorOffset = index >> 8;

                _filePointer.Seek(sectorOffset*4096, SeekOrigin.Begin);

                int chunkLength = _filePointer.ReadInt32();
                if (chunkLength == -1) return null; // Not yet generated
                byte compressionMode = _filePointer.ReadByte();

                MemoryStream decompressStream;
                if (compressionMode == 0)
                {

                }
                if (compressionMode == 1)
                {
                    byte[] buffer = new byte[chunkLength];
                    _filePointer.Read(buffer, 0, buffer.Length);
                    buffer = Decompress(buffer);
                    decompressStream = new MemoryStream(buffer);
                }
                else
                {
                    byte[] buffer = new byte[chunkLength];
                    _filePointer.Read(buffer, 0, buffer.Length);
                    var def = new Inflater();
                    decompressStream = new MemoryStream();
                    def.setInput(buffer);
                    int i = 0;
                    buffer = new byte[1024*1024];
                    try
                    {
                        while (!def.finished() && (i = def.inflate(buffer)) > 0)
                        {
                            decompressStream.Write(buffer, 0, i);

                        }
                    }
                    catch
                    {
                        return null;
                    }
                    decompressStream.Seek(0, SeekOrigin.Begin);
                }
                return new NbtReader().ReadNbtFile(decompressStream);
            }
        }
开发者ID:pdelvo,项目名称:Minecraft-Test-Converter,代码行数:56,代码来源:LevelLoader.cs

示例3: 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

示例4: Main

    public static void Main(string [] args)
    {
        if (args.Length == 0 || args.Length > 3) {
            Console.WriteLine ("Usage: zipmark FILE [ITERATIONS] [BLOCKSIZE]");
            return;
        }

        string filename = args [0];
        FileInfo file = new FileInfo (filename);
        if (!file.Exists) {
            Console.WriteLine ("Couldn't find file {0}", filename);
            return;
        }

        FileStream fs = file.OpenRead ();

        byte [] raw = new byte [file.Length];
        int count = fs.Read (raw, 0, (int)file.Length);
        fs.Close ();

        if (count != file.Length) {
            Console.WriteLine ("Couldn't read file {0}", filename);
            return;
        }

        Deflater def = new Deflater (Deflater.BEST_COMPRESSION, false);
        Inflater inf = new Inflater (false);

        // 1. Count deflated size

        int cooked_size = Deflate (def, raw, null);
        byte [] cooked = new byte [cooked_size];

        // 2. Deflate & Inflate

        if (args.Length > 1)
            Iterations = Int32.Parse (args [1]);
        if (args.Length > 2)
            BlockSize = Int32.Parse (args [2]);

        for (int i = 0; i < Iterations; ++ i) {
            Deflate (def, raw, cooked);
            Inflate (inf, cooked, raw);
        }

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

示例5: GZipStream

	public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
			{
				if(stream == null)
				{
					throw new ArgumentNullException("stream");
				}
				if(mode == CompressionMode.Decompress)
				{
					if(!stream.CanRead)
					{
						throw new ArgumentException
							(S._("IO_NotReadable"), "stream");
					}
				}
				else if(mode == CompressionMode.Compress)
				{
					if(!stream.CanWrite)
					{
						throw new ArgumentException
							(S._("IO_NotWritable"), "stream");
					}
				}
				else
				{
					throw new ArgumentException
						(S._("IO_CompressionMode"), "mode");
				}
				this.stream = stream;
				this.mode = mode;
				this.leaveOpen = leaveOpen;
				this.buf = new byte [4096];
				this.crc32 = new Crc32();
				this.endOfStream = false;
				this.headerDone = false;
				if(mode == CompressionMode.Decompress)
				{
					inflater = new Inflater(true);
				}
				else
				{
					deflater = new Deflater(-1, true);
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:43,代码来源:GZipStream.cs

示例6: InflaterInputStream

 public InflaterInputStream(Stream baseInputStream, Inflater inflater, int bufferSize)
 {
     this.isClosed = false;
     this.isStreamOwner = true;
     if (baseInputStream == null)
     {
         throw new ArgumentNullException("InflaterInputStream baseInputStream is null");
     }
     if (inflater == null)
     {
         throw new ArgumentNullException("InflaterInputStream Inflater is null");
     }
     if (bufferSize <= 0)
     {
         throw new ArgumentOutOfRangeException("bufferSize");
     }
     this.baseInputStream = baseInputStream;
     this.inf = inflater;
     this.inputBuffer = new InflaterInputBuffer(baseInputStream);
 }
开发者ID:fanthos,项目名称:Game-Heal,代码行数:20,代码来源:InflaterInputStream.cs

示例7: DeflateStream

	public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen)
			{
				if(stream == null)
				{
					throw new ArgumentNullException("stream");
				}
				if(mode == CompressionMode.Decompress)
				{
					if(!stream.CanRead)
					{
						throw new ArgumentException
							(S._("IO_NotReadable"), "stream");
					}
				}
				else if(mode == CompressionMode.Compress)
				{
					if(!stream.CanWrite)
					{
						throw new ArgumentException
							(S._("IO_NotWritable"), "stream");
					}
				}
				else
				{
					throw new ArgumentException
						(S._("IO_CompressionMode"), "mode");
				}
				this.stream = stream;
				this.mode = mode;
				this.leaveOpen = leaveOpen;
				this.buf = new byte [4096];
				if(mode == CompressionMode.Decompress)
				{
					inflater = new Inflater();
				}
				else
				{
					deflater = new Deflater();
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:40,代码来源:DeflateStream.cs

示例8: DeflateStream

        internal DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen, bool usingGZip)
        {
            _stream = stream;
            _mode = mode;
            _leaveOpen = leaveOpen;

            if (_stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            switch (_mode)
            {
                case CompressionMode.Decompress:
                    if (!(_stream.CanRead))
                    {
                        throw new ArgumentException("SR.NotReadableStream");
                    }
                    _inflater = new Inflater(usingGZip);
                    _mCallBack = new AsyncCallback(ReadCallback);
                    break;

                case CompressionMode.Compress:
                    if (!(_stream.CanWrite))
                    {
                        throw new ArgumentException("SR.NotWriteableStream");
                    }
                    _deflater = new Deflater(usingGZip);
                    _mAsyncWriterDelegate = new AsyncWriteDelegate(this.InternalWrite);
                    _mCallBack = new AsyncCallback(WriteCallback);
                    break;

                default:
                    throw new ArgumentException("SR.ArgumentOutOfRange_Enum");
            }
            _buffer = new byte[BufferSize];
        }
开发者ID:Gert-Cominotto,项目名称:MvvmCross,代码行数:37,代码来源:DeflateStream.cs

示例9: 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

示例10: 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

示例11: ReadableDeflateTransform

 public ReadableDeflateTransform(int bits)
 {
     _inflater = new Inflater(bits);
 }
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:4,代码来源:CompressionPipelineExtensions.cs

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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