Click or drag to resize

PatternCompressorCompressBuffer Method

Compress a byte array containing a sequential list of 32-bit structures (e.g., floating point numbers, integers or unsigned integers) using a patterned compression method.

Namespace: GSF.IO.Compression
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax
public static int CompressBuffer(
	byte[] source,
	int startIndex,
	int dataLength,
	int bufferLength,
	byte compressionStrength = 5
)
View Source

Parameters

source  Byte
The Byte array containing 32-bit values to compress. Compression will happen inline on this buffer.
startIndex  Int32
An Int32 representing the start index of the byte array.
dataLength  Int32
The number of bytes in the buffer that represents actual data.
bufferLength  Int32
The number of bytes available for use in the buffer; actual buffer length must be at least one byte larger than dataLength since it's possible that data cannot be compressed. This extra byte will be used indicate an uncompressed buffer.
compressionStrength  Byte  (Optional)
Specifies compression strength (0 to 31). Smaller numbers will run faster, larger numbers will yield better compression.

Return Value

Int32
The new length of the buffer after compression.
Exceptions
ExceptionCondition
ArgumentNullExceptionsource buffer cannot be null.
ArgumentOutOfRangeExceptiondataLength must be greater than or equal to zero.
ArgumentExceptiondataLength must be an even multiple of 4.
ArgumentOutOfRangeExceptionbufferLength must be at least one byte larger than dataLength in case data cannot be compressed.
ArgumentOutOfRangeExceptionActual length of source buffer is less than specified bufferLength.
ArgumentOutOfRangeExceptioncompressionStrength must be 0 to 31.
Remarks
As an optimization this function is using pointers to native structures, as such the endian order decoding and encoding of the values will always be in the native endian order of the operating system.
See Also