|
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.CompressionAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.248-beta+a497a19de709fd99e2448886199a2c8824265ddf
Syntaxpublic static int CompressBuffer(
byte[] source,
int startIndex,
int dataLength,
int bufferLength,
byte compressionStrength = 5
)
Public Shared Function CompressBuffer (
source As Byte(),
startIndex As Integer,
dataLength As Integer,
bufferLength As Integer,
Optional compressionStrength As Byte = 5
) As Integer
public:
static int CompressBuffer(
array<unsigned char>^ source,
int startIndex,
int dataLength,
int bufferLength,
unsigned char compressionStrength = 5
)
static member CompressBuffer :
source : byte[] *
startIndex : int *
dataLength : int *
bufferLength : int *
?compressionStrength : byte
(* Defaults:
let _compressionStrength = defaultArg compressionStrength 5
*)
-> int
GSF.IO.Compression.PatternCompressor.CompressBuffer = function(source, startIndex, dataLength, bufferLength, compressionStrength);
View SourceParameters
- 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
Int32The new length of the buffer after compression.
ExceptionsException | Condition |
---|
ArgumentNullException | source buffer cannot be null. |
ArgumentOutOfRangeException | dataLength must be greater than or equal to zero. |
ArgumentException | dataLength must be an even multiple of 4. |
ArgumentOutOfRangeException | bufferLength must be at least one byte larger than dataLength in case data cannot be compressed. |
ArgumentOutOfRangeException | Actual length of source buffer is less than specified bufferLength. |
ArgumentOutOfRangeException | compressionStrength 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