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


C# Compression.Inflater类代码示例

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


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

示例1: DecompressZLib

		/// <summary>
		/// Performs inflate decompression on the given data.
		/// </summary>
		/// <param name="input">the data to decompress</param>
		/// <param name="output">the decompressed data</param>
		public static void DecompressZLib(byte[] input, byte[] output)
		{
			Inflater item = new Inflater();

			item.SetInput(input, 0, input.Length);
			item.Inflate(output, 0, output.Length);
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:12,代码来源:Compression.cs

示例2: ZlibStream

 public ZlibStream(Stream inner, Inflater inflater, int buffSize)
 {
     _innerStream = inner;
     _in = inflater;
     _inBuff = new byte[buffSize];
     _outBuff = _inBuff;
     _out = new Deflater();
 }
开发者ID:nickwhaley,项目名称:ubiety,代码行数:8,代码来源:ZlibStream.cs

示例3: Inflate

		void Inflate(MemoryStream ms, byte[] original, int level, bool zlib)
		{
			ms.Seek(0, SeekOrigin.Begin);
			
			Inflater inflater = new Inflater(!zlib);
			InflaterInputStream inStream = new InflaterInputStream(ms, inflater);
			byte[] buf2 = new byte[original.Length];

			int currentIndex  = 0;
			int count = buf2.Length;

			try
			{
				while (true) 
				{
					int numRead = inStream.Read(buf2, currentIndex, count);
					if (numRead <= 0) 
					{
						break;
					}
					currentIndex += numRead;
					count -= numRead;
				}
			}
			catch(Exception ex)
			{
				Console.WriteLine("Unexpected exception - '{0}'", ex.Message);
				throw;
			}

			if ( currentIndex != original.Length )
			{
				Console.WriteLine("Original {0}, new {1}", original.Length, currentIndex);
				Assert.Fail("Lengths different");
			}

			for (int i = 0; i < original.Length; ++i) 
			{
				if ( buf2[i] != original[i] )
				{
					string description = string.Format("Difference at {0} level {1} zlib {2} ", i, level, zlib);
					if ( original.Length < 2048 )
					{
						StringBuilder builder = new StringBuilder(description);
						for (int d = 0; d < original.Length; ++d)
						{
							builder.AppendFormat("{0} ", original[d]);
						}

						Assert.Fail(builder.ToString());
					}
					else
					{
						Assert.Fail(description);
					}
				}
			}
		}
开发者ID:JoeCooper,项目名称:SharpZipLib.Portable,代码行数:58,代码来源:InflaterDeflaterTests.cs

示例4: SetInput

		/// <exception cref="Sharpen.DataFormatException"></exception>
		protected internal override int SetInput(int pos, Inflater inf)
		{
			ByteBuffer s = buffer.Slice();
			s.Position(pos);
			byte[] tmp = new byte[Math.Min(s.Remaining(), 512)];
			s.Get(tmp, 0, tmp.Length);
			inf.SetInput(tmp, 0, tmp.Length);
			return tmp.Length;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:10,代码来源:ByteBufferWindow.cs

示例5: Decrypt

		byte[] Decrypt(byte[] encryptedData) {
			var reader = new BinaryReader(new MemoryStream(encryptedData));
			int headerMagic = reader.ReadInt32();
			if (headerMagic == 0x04034B50)
				throw new NotImplementedException("Not implemented yet since I haven't seen anyone use it.");

			byte encryption = (byte)(headerMagic >> 24);
			if ((headerMagic & 0x00FFFFFF) != 0x007D7A7B)	// Check if "{z}"
				throw new ApplicationException(string.Format("Invalid SA header magic 0x{0:X8}", headerMagic));

			switch (encryption) {
			case 1:
				int totalInflatedLength = reader.ReadInt32();
				if (totalInflatedLength < 0)
					throw new ApplicationException("Invalid length");
				var inflatedBytes = new byte[totalInflatedLength];
				int partInflatedLength;
				for (int inflateOffset = 0; inflateOffset < totalInflatedLength; inflateOffset += partInflatedLength) {
					int partLength = reader.ReadInt32();
					partInflatedLength = reader.ReadInt32();
					if (partLength < 0 || partInflatedLength < 0)
						throw new ApplicationException("Invalid length");
					var inflater = new Inflater(true);
					inflater.SetInput(encryptedData, checked((int)reader.BaseStream.Position), partLength);
					reader.BaseStream.Seek(partLength, SeekOrigin.Current);
					int realInflatedLen = inflater.Inflate(inflatedBytes, inflateOffset, inflatedBytes.Length - inflateOffset);
					if (realInflatedLen != partInflatedLength)
						throw new ApplicationException("Could not inflate");
				}
				return inflatedBytes;

			case 2:
				if (resourceDecrypterInfo.DES_Key == null || resourceDecrypterInfo.DES_IV == null)
					throw new ApplicationException("DES key / iv have not been set yet");
				using (var provider = new DESCryptoServiceProvider()) {
					provider.Key = resourceDecrypterInfo.DES_Key;
					provider.IV  = resourceDecrypterInfo.DES_IV;
					using (var transform = provider.CreateDecryptor()) {
						return Decrypt(transform.TransformFinalBlock(encryptedData, 4, encryptedData.Length - 4));
					}
				}

			case 3:
				if (resourceDecrypterInfo.AES_Key == null || resourceDecrypterInfo.AES_IV == null)
					throw new ApplicationException("AES key / iv have not been set yet");
				using (var provider = new RijndaelManaged()) {
					provider.Key = resourceDecrypterInfo.AES_Key;
					provider.IV  = resourceDecrypterInfo.AES_IV;
					using (var transform = provider.CreateDecryptor()) {
						return Decrypt(transform.TransformFinalBlock(encryptedData, 4, encryptedData.Length - 4));
					}
				}

			default:
				throw new ApplicationException(string.Format("Unknown encryption type 0x{0:X2}", encryption));
			}
		}
开发者ID:ximing-kooboo,项目名称:de4dot,代码行数:57,代码来源:ResourceDecrypter.cs

示例6: DecompressDeflate

        public static byte[] DecompressDeflate(byte[] data, int decompSize)
        {
            var decompData = new byte[decompSize];

            var inflater = new Inflater(true);
            inflater.SetInput(data);
            inflater.Inflate(decompData);

            return decompData;
        }
开发者ID:tjhorner,项目名称:gtaivtools,代码行数:10,代码来源:DataUtil.cs

示例7: DecompressAlphaValues

        public static byte[] DecompressAlphaValues(byte[] alphaValues, int width, int height)
        {
            var data = new byte[width * height];
            var inflater = new Inflater();
            inflater.SetInput(alphaValues);
            if (inflater.Inflate(data) != data.Length)
                throw new ArgumentException("Alpha values are not in valid compressed format!");

            return data;
        }
开发者ID:kaldap,项目名称:XnaFlash,代码行数:10,代码来源:BitmapUtils.cs

示例8: Decompress

 /// <summary>
 /// ��ѹ�ֽ�������
 /// </summary>
 /// <param name="val">��������ֽ�������</param>
 /// <returns>���ؽ�ѹ�������</returns>
 public byte[] Decompress(byte[] val)
 {
     if (val[0] == 1) {
         Inflater inflater = new Inflater(true);
         using (InflaterInputStream decompressStream = new InflaterInputStream(new MemoryStream(UnwrapData(val)), inflater)) {
             return ArrayHelper.ReadAllBytesFromStream(decompressStream);
         }
     }
     else
         return UnwrapData(val);
 }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:16,代码来源:Compressor.cs

示例9: ChunkedChanges

        public ChunkedChanges(bool compressed, CancellationToken token, ManualResetEventSlim pauseWait)
        {
            _innerStream = new ChunkStream();
            _innerStream.BookmarkReached += (sender, args) => OnCaughtUp?.Invoke(this, null);
            if (compressed) {
                _inflater = new Inflater(true);
            }

            token.Register(Dispose);
            _pauseWait = pauseWait;
            Task.Factory.StartNew(Process, TaskCreationOptions.LongRunning);
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:12,代码来源:ChunkedChanges.cs

示例10: HandleReqUpdateAccountData

 public static void HandleReqUpdateAccountData(Packet packet)
 {
     packet.ReadEnum<AccountDataType>("Type");
     packet.ReadTime("Time");
     int inflatedSize = packet.ReadInt32("Size");
     byte[] compressedData = packet.ReadBytes((int)packet.GetLength() - (int)packet.GetPosition());
     byte[] data = new byte[inflatedSize];
     var inflater = new Inflater();
     inflater.SetInput(compressedData, 0, compressedData.Length);
     inflater.Inflate(data, 0, inflatedSize);
     Console.WriteLine("Data: {0}", encoder.GetString(data));
 }
开发者ID:AwkwardDev,项目名称:StrawberryTools,代码行数:12,代码来源:CharacterHandler.cs

示例11: Decompress

 public static byte[] Decompress(byte[] compressed, uint unzippedSize)
 {
     byte[] result = new byte[unzippedSize];
     Inflater inf = new Inflater();
     inf.SetInput(compressed);
     int error = inf.Inflate(result, 0, (int)unzippedSize);
     if (error == 0)
     {
         throw new FileLoadException("The a section of the swf file could not be decompressed.");
     }
     return result;
 }
开发者ID:Hamsand,项目名称:Swf2XNA,代码行数:12,代码来源:SwfReader.cs

示例12: CodecInputStream

 public CodecInputStream(Stream baseStream)
 {
     BinaryReader br = new BinaryReader(baseStream);
     decompressedSize = br.ReadInt32();
     compressedSize = br.ReadInt32();
     byte[] inbuf = new byte[compressedSize];
     baseStream.Read(inbuf, 0, compressedSize);
     Inflater inflater = new Inflater(false);
     inflater.SetInput(inbuf);
     byte[] buf = new byte[decompressedSize];
     inflater.Inflate(buf);
     this.iis = new MemoryStream(buf);
 }
开发者ID:Gayo,项目名称:Gayo-CAROT,代码行数:13,代码来源:CodecInputStream.cs

示例13: inflateVerify

		protected override void inflateVerify(int pos, Inflater inf)
        {
            while (!inf.IsFinished)
            {
                if (inf.IsNeedingInput)
                {
                    inf.SetInput(_array, pos, _array.Length - pos);
                    break;
                }
                inf.Inflate(VerifyGarbageBuffer, 0, VerifyGarbageBuffer.Length);
            }
            while (!inf.IsFinished && !inf.IsNeedingInput)
                inf.Inflate(VerifyGarbageBuffer, 0, VerifyGarbageBuffer.Length);
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:14,代码来源:ByteArrayWindow.cs

示例14: Inflate

 protected override int Inflate(int pos, byte[] b, int o, Inflater inf)
 {
     while (!inf.IsFinished)
     {
         if (inf.IsNeedingInput)
         {
             inf.SetInput(_array, pos, _array.Length - pos);
             break;
         }
         o += inf.Inflate(b, o, b.Length - o);
     }
     while (!inf.IsFinished && !inf.IsNeedingInput)
         o += inf.Inflate(b, o, b.Length - o);
     return o;
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:15,代码来源:ByteArrayWindow.cs

示例15: Inflate

		protected override int Inflate(int pos, byte[] dstbuf, int dstoff, Inflater inf)
        {
            while (!inf.IsFinished)
            {
                if (inf.IsNeedingInput)
                {
                    inf.SetInput(_array, pos, _array.Length - pos);
                    break;
                }
                dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
            }
            while (!inf.IsFinished && !inf.IsNeedingInput)
                dstoff += inf.Inflate(dstbuf, dstoff, dstbuf.Length - dstoff);
            return dstoff;
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:15,代码来源:ByteArrayWindow.cs


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