Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Xie committed May 23, 2021
1 parent 0f4bc44 commit 7d4db85
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,22 @@ For compression provider sample, please check the Brotli.CompressionProvider.Sam
### Compress

```C#
public Byte[] Encode(Byte[] input)
{
Byte[] output = null;
using (System.IO.MemoryStream msInput = new System.IO.MemoryStream(input))
using (System.IO.MemoryStream msOutput = new System.IO.MemoryStream())
using (BrotliStream bs = new BrotliStream(msOutput, System.IO.Compression.CompressionMode.Compress))
{
bs.SetQuality(11);
bs.SetWindow(22);
msInput.CopyTo(bs);
bs.Close();
output = msOutput.ToArray();
return output;
}
}
//the first parameter controls the quality(0-11)
var compressedData=inputBytes.CompressToBrotli(5,22);
//or
var compressedData=inputSteam.CompressToBrotli();
//or
inputStream.CompressToBrotli(destStream)
```

### Decompress

```C#
public Byte[] Decode(Byte[] input)
{
using (System.IO.MemoryStream msInput = new System.IO.MemoryStream(input))
using (BrotliStream bs = new BrotliStream(msInput, System.IO.Compression.CompressionMode.Decompress))
using (System.IO.MemoryStream msOutput = new System.IO.MemoryStream())
{
bs.CopyTo(msOutput);
msOutput.Seek(0, System.IO.SeekOrigin.Begin);
output = msOutput.ToArray();
return output;
}
}
var decompressedData=inputBytes.DecompressFromBrotli();
//or
var decompressedData=inputSteam.DecompressFromBrotli();
//or
inputSteam.DecompressFromBrotli(destStream);
```

### Dynamic compress support(Legacy .NET Mvc)
Expand Down

0 comments on commit 7d4db85

Please sign in to comment.