本文整理汇总了C#中Inflater.SetInput方法的典型用法代码示例。如果您正苦于以下问题:C# Inflater.SetInput方法的具体用法?C# Inflater.SetInput怎么用?C# Inflater.SetInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inflater
的用法示例。
在下文中一共展示了Inflater.SetInput方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: 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;
}
}
示例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();
}
示例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;
}
}
示例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;
}
示例6: SetInflaterInput
public void SetInflaterInput(Inflater inflater)
{
if (this.available > 0)
{
inflater.SetInput(this.clearText, this.clearTextLength - this.available, this.available);
this.available = 0;
}
}
示例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;
}
示例8: 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);
}