public void DecodeStream() { // Reset position to use same buffer zlibMemoryStream.Position = 0; // Get compressed stream length to read byte[] buff = new byte[4]; if (this.BaseStream.Read(buff, 0, 4) != 4) { throw new Exception("ZRLE decoder: Invalid compressed stream size"); } // BigEndian to LittleEndian conversion int compressedBufferSize = (int)(buff[3] | buff[2] << 8 | buff[1] << 16 | buff[0] << 24); if (compressedBufferSize > 64 * 1024 * 1024) { throw new Exception("ZRLE decoder: Invalid compressed data size"); } // Decode stream int pos = 0; while (pos++ < compressedBufferSize) { zlibDecompressedStream.WriteByte(this.BaseStream.ReadByte()); } zlibMemoryStream.Position = 0; }
public override void WriteByte( byte b) { _out.WriteByte(b); }