IBufferCodec

Description

interface Tinman.Terrain.Codec.IBufferCodec

Extended by

ColorBuffer sealed
TexelBuffer abstract

Base interface for sample buffers that supporting encoding/decoding of buffer sample blocks to losslessly compressed byte sequences.

Public / Methods

Buffer​Decode


public method BufferDecode → (3)

input in : ByteBuffer

[not-null]
The input buffer.

in : int32

[0..]
X-coordinate of top-left sample of block to decode.

in : int32

[0..]
Y-coordinate of top-left sample of block to decode.

Decodes a block of samples in this buffer.

IOException

If the binary format input in is malformed.

Buffer​Encode


public method BufferEncode → (5)

output in : ByteBuffer

[not-null]
The output buffer.

in : int32

[0..]
X-coordinate of top-left sample of block to encode.

in : int32

[0..]
Y-coordinate of top-left sample of block to encode.

width in : int32

[0..-x]
Width of pixel block.

height in : int32

[0..-y]
Height of pixel block.

returns → int32

>0 : The number of bytes that have been written to output in.
<0 : The output buffer is too small, at least -1-n bytes are required, where n is the return value.

Encodes a block of samples in this buffer as a sequence of bytes, using lossless compression.

Public / Attributes

Buffer​Size


public attribute BufferSize → (get)

value : int32

[>0]
The uncompressed buffer size, in bytes.

Returns the size in bytes of the uncompressed samples in this buffer.

The returned value is suitable to be used as the initial guess for the output buffer size when calling BufferEncode. If the buffer content exhibits very high entropy, BufferEncode is likely to overflow when using BufferSize. In these cases, increasing the buffer size by a factor of 6/5 will usually be enough. In any case, the return value of BufferEncode must always be inspected and the overflow case must always be handled properly.

Extensions

Buffer​Encode


[OwnerReturn]
public static method BufferEncode → (4)

in : int32

[>=0]
X-coordinate of top-left sample of block to encode.

in : int32

[>=0]
Y-coordinate of top-left sample of block to encode.

width in : int32

[>=0]
Width of pixel block.

height in : int32

[>=0]
Height of pixel block.

returns → ByteBuffer

The resulting buffer. The position and limit encompass the compressed byte data.

Encodes a block of samples in this buffer as a sequence of bytes, using lossless compression.