/// <exception cref="System.IO.IOException"/> private byte[] Decompress(byte[] data, bool byByte) { byte[] buffer = new byte[65536]; System.IO.MemoryStream input = new System.IO.MemoryStream(data); System.IO.MemoryStream output = new System.IO.MemoryStream(); iText.IO.Codec.Brotli.Dec.BrotliInputStream brotliInput = new iText.IO.Codec.Brotli.Dec.BrotliInputStream(input); if (byByte) { byte[] oneByte = new byte[1]; while (true) { int next = brotliInput.ReadByte(); if (next == -1) { break; } oneByte[0] = unchecked ((byte)next); output.Write(oneByte, 0, 1); } } else { while (true) { int len = brotliInput.Read(buffer, 0, buffer.Length); if (len <= 0) { break; } output.Write(buffer, 0, len); } } brotliInput.Dispose(); return(output.ToArray()); }
/// <exception cref="System.IO.IOException"/> private byte[] DecompressWithDictionary(byte[] data, byte[] dictionary) { byte[] buffer = new byte[65536]; System.IO.MemoryStream input = new System.IO.MemoryStream(data); System.IO.MemoryStream output = new System.IO.MemoryStream(); iText.IO.Codec.Brotli.Dec.BrotliInputStream brotliInput = new iText.IO.Codec.Brotli.Dec.BrotliInputStream(input, iText.IO.Codec.Brotli.Dec.BrotliInputStream.DefaultInternalBufferSize, dictionary); while (true) { int len = brotliInput.Read(buffer, 0, buffer.Length); if (len <= 0) { break; } output.Write(buffer, 0, len); } brotliInput.Dispose(); return(output.ToArray()); }