public byte[] Compress(byte[] arg) { var result = new LZNT1_Buffer(); var chunks = new List <LZNT1_Chunk>(); int index = 0; while (index < arg.Length) { int length = Math.Min(arg.Length - index, 4096); var chunk = CompressChunk(arg.Skip(index).Take(length).ToArray()); chunks.Add(chunk); index += length; } result.Chunk = chunks.ToArray(); var buffer = new LittleEndianByteBuffer(); int offset = 0; result.Marshal(buffer, ref offset); return(buffer.GetBytes()); }
public override object Unmarshal(LittleEndianByteBuffer buffer, ref int offset) { var result = new LZNT1_Buffer(); var chunks = new List <LZNT1_Chunk>(); while (offset < buffer.Count) { var chunk = Unmarshal <LZNT1_Chunk>(buffer, ref offset); chunks.Add(chunk); } result.Chunk = chunks.ToArray(); return(result); }