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


C# Inflater.SetInput方法代码示例

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


在下文中一共展示了Inflater.SetInput方法的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: 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

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

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

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

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

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

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

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

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

示例11: Decompress

        public static byte[] Decompress(byte[] input, int uncompressedLength, bool header = true)
        {
            Contract.Requires(input != null);
            Contract.Requires(uncompressedLength >= 0);
            Contract.Ensures(Contract.Result<byte[]>() != null);
            Contract.Ensures(Contract.Result<byte[]>().Length == uncompressedLength);

            var inflater = new Inflater(!header);
            var output = new byte[uncompressedLength];

            inflater.SetInput(input, 0, input.Length);
            inflater.Inflate(output);

            return output;
        }
开发者ID:hanson-huang,项目名称:Encore,代码行数:15,代码来源:ZLibDecompressor.cs

示例12: Decompress

		public static byte[] Decompress(byte[] content, int offset, int count)
		{
			//return content;
			Inflater decompressor = new Inflater();
			decompressor.SetInput(content, offset, count);

			using (MemoryStream bos = new MemoryStream(content.Length))
			{
				var buf = new byte[1024];
				while (!decompressor.IsFinished)
				{
					int n = decompressor.Inflate(buf);
					bos.Write(buf, 0, n);
				}
				return bos.ToArray();
			}
		}
开发者ID:egametang,项目名称:Egametang,代码行数:17,代码来源:ZipHelper.cs

示例13: Open

 public Stream Open(Stream stream)
 {
     stream.Seek(DataOffset, SeekOrigin.Begin);
     byte[] data;
     if (DataCompression == 0)
     {
         data = stream.ReadBytes(DataSize);
     }
     else
     {
         var dataBuffer = stream.ReadBytes(DataCompressedSize);
         var inflater = new Inflater(false);
         inflater.SetInput(dataBuffer);
         data = new Byte[DataSize];
         inflater.Inflate(data);
     }
     return new MemoryStream(data);
 }
开发者ID:wverkley,项目名称:Swg.Explorer,代码行数:18,代码来源:TREFile.cs

示例14: Uncompress

        public byte[] Uncompress(byte[] input)
        {
            Inflater decompressor = new Inflater();
            decompressor.SetInput(input);

            // Create an expandable byte array to hold the decompressed data
            MemoryStream bos = new MemoryStream(input.Length);

            // Decompress the data
            byte[] buf = new byte[1024];
            while (!decompressor.IsFinished)
            {
                int count = decompressor.Inflate(buf);
                bos.Write(buf, 0, count);
            }

            // Get the decompressed data
            return bos.ToArray();
        }
开发者ID:zweib730,项目名称:beagrep,代码行数:19,代码来源:SharpZipLibAdapter.cs

示例15: Inflate

 	protected override int Inflate(int pos, byte[] dstbuf, int dstoff, Inflater inf)
     {
         var tmp = new byte[512];
         var s = _stream;
         s.Position=pos;
         while ((s.Length-s.Position) > 0 && !inf.IsFinished)
         {
             if (inf.IsNeedingInput)
             {
                 var n = (int)Math.Min((s.Length - s.Position), tmp.Length);
                 s.Read(tmp, 0, n);
                 inf.SetInput(tmp, 0, n);
             }
             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,代码行数:19,代码来源:ByteBufferWindow.cs


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