BrotliEncoder.TryCompress Method

Definition

Overloads

TryCompress(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Tries to compress a source byte span into a destination span.

TryCompress(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Int32)

Tries to compress a source byte span into a destination byte span, using the provided compression quality leven and encoder window bits.

TryCompress(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Source:
BrotliEncoder.cs
Source:
BrotliEncoder.cs
Source:
BrotliEncoder.cs

Tries to compress a source byte span into a destination span.

C#
public static bool TryCompress(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten);

Parameters

source
ReadOnlySpan<Byte>

A read-only span of bytes containing the source data to compress.

destination
Span<Byte>

When this method returns, a span of bytes where the compressed data is stored.

bytesWritten
Int32

When this method returns, the total number of bytes that were written to destination.

Returns

true if the compression operation was successful; false otherwise.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

TryCompress(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Int32)

Source:
BrotliEncoder.cs
Source:
BrotliEncoder.cs
Source:
BrotliEncoder.cs

Tries to compress a source byte span into a destination byte span, using the provided compression quality leven and encoder window bits.

C#
public static bool TryCompress(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesWritten, int quality, int window);

Parameters

source
ReadOnlySpan<Byte>

A read-only span of bytes containing the source data to compress.

destination
Span<Byte>

When this method returns, a span of bytes where the compressed data is stored.

bytesWritten
Int32

When this method returns, the total number of bytes that were written to destination.

quality
Int32

A number representing quality of the Brotli compression. 0 is the minimum (no compression), 11 is the maximum.

window
Int32

A number representing the encoder window bits. The minimum value is 10, and the maximum value is 24.

Returns

true if the compression operation was successful; false otherwise.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1