public void WriteTo(Stream stream) { stream.Write(this.byte_0, 0, this.byte_0.Length); stream.WriteByte(this.byte_1); switch (this.byte_1) { case 1: this.method_0(stream); break; case 2: using (ZlibCompressStream zlibCompressStream = new ZlibCompressStream(stream, true)) { try { this.method_0((Stream)zlibCompressStream); break; } finally { zlibCompressStream.Flush(); } } default: throw new InternalException("Undefined WWF version " + (object)this.byte_1 + "!"); } }
public byte[] Encode(byte[] data) { using (MemoryStream memoryStream = new MemoryStream(data.Length)) { using (ZlibCompressStream zlibCompressStream = new ZlibCompressStream((Stream)memoryStream, true)) zlibCompressStream.Write(data, 0, data.Length); return(memoryStream.ToArray()); } }
public void WriteTo(Stream stream) { byte[] bytes = Encodings.Ascii.GetBytes("PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec"); stream.Write(bytes, 0, bytes.Length); MemoryStream memoryStream1 = new MemoryStream(); this.method_1(new CtbFile.Class1003((Stream)memoryStream1)); MemoryStream memoryStream2 = new MemoryStream((int)memoryStream1.Length); using (ZlibCompressStream zlibCompressStream = new ZlibCompressStream((Stream)memoryStream2, true)) { memoryStream1.WriteTo((Stream)zlibCompressStream); zlibCompressStream.Flush(); } uint num = CtbFile.smethod_0(memoryStream2.GetBuffer(), 0, (int)memoryStream2.Length); CtbFile.smethod_7(stream, num); CtbFile.smethod_7(stream, (uint)memoryStream1.Length); CtbFile.smethod_7(stream, (uint)memoryStream2.Length); memoryStream2.WriteTo(stream); }