private void DecodeFile(FileDecodingInputStream inputStream, BootstrapSegment bootstrapSegment, CancellationToken cancellationToken, IProgressHandler progressHandler) { FileSegment file = streamParser.ParseFile(inputStream, bootstrapSegment.WeightsTable); string path = Path.Combine(currentDirectory, file.Name); using (FileDecodingOutputStream outputStream = new FileDecodingOutputStream(path, platform)) { file.FileDecoder.Decode(outputStream, cancellationToken, progressHandler); } }
public void WriteSymbolTest() { MemoryStream memoryStream = new MemoryStream(); using (FileDecodingOutputStream stream = CreateFileDecodingOutputStream(memoryStream)) { stream.WriteSymbol(001); stream.WriteSymbol(005); stream.WriteSymbol(250); stream.WriteSymbol(255); stream.WriteSymbol(0); Assert.AreEqual(new byte[] { 1, 5, 250, 255, 0 }, memoryStream.ToArray()); } }
private byte[] Decode(byte[] code, HuffmanTreeBase tree, long streamSize) { MemoryStream outputMemoryStream = new MemoryStream(); FileDecodingInputStream inputStream = CreateFileDecodingInputStream(code); FileDecodingOutputStream outputStream = CreateFileDecodingOutputStream(outputMemoryStream); try { new HuffmanDecoder().Decode(inputStream, tree, outputStream, streamSize, CancellationToken.None, null); return(outputMemoryStream.ToArray()); } finally { inputStream.Dispose(); outputStream.Dispose(); } }