libsdfio 1.0.0
Reader and writer for ISO 25178-71 SDF surface data files in C
Loading...
Searching...
No Matches
sizes.h File Reference

Sizes of buffers for the data area and for heights. More...

#include <sdfio/header.h>
#include <sdfio/sdfio_export.h>
#include <sdfio/types.h>
#include <stddef.h>

Go to the source code of this file.

Functions

sdfio_status sdfio_data_size (const sdfio_header *header, size_t *bytes)
 Returns the size in bytes of a buffer for the whole data area: header->rows times header->columns coded values of header->data_type.
sdfio_status sdfio_data_row_size (const sdfio_header *header, size_t *bytes)
 Returns the size in bytes of a buffer for one row of the data area, to read or write the data row by row with sdfio_read_data() and sdfio_write_data().
sdfio_status sdfio_heights_size (const sdfio_header *header, sdfio_data_type type, size_t *bytes)
 Returns the size in bytes of a buffer for the whole matrix of heights in a type, for sdfio_read_heights() and sdfio_write_heights().
sdfio_status sdfio_heights_row_size (const sdfio_header *header, sdfio_data_type type, size_t *bytes)
 Returns the size in bytes of a buffer for one row of heights in a type, for sdfio_decode_heights() and sdfio_encode_heights() of one row of the data area.

Detailed Description

Sizes of buffers for the data area and for heights.

Function Documentation

◆ sdfio_data_row_size()

sdfio_status sdfio_data_row_size ( const sdfio_header * header,
size_t * bytes )

Returns the size in bytes of a buffer for one row of the data area, to read or write the data row by row with sdfio_read_data() and sdfio_write_data().

Parameters
[in]headerThe header of the file.
[out]bytesThe size, which is 0 for a row without columns.
Return values
SDFIO_ERR_ARGUMENTA pointer is null or the data type is invalid.
SDFIO_ERR_RANGEThe size cannot be represented in a size_t.
Examples
read_coded.c, and read_stream.c.

◆ sdfio_data_size()

sdfio_status sdfio_data_size ( const sdfio_header * header,
size_t * bytes )

Returns the size in bytes of a buffer for the whole data area: header->rows times header->columns coded values of header->data_type.

The size is checked for arithmetic overflow. A buffer of this size is suitable for sdfio_read_data() and sdfio_decode_heights(). The caller allocates it.

Parameters
[in]headerThe header of the file.
[out]bytesThe size, which is 0 for an empty matrix.
Return values
SDFIO_ERR_ARGUMENTA pointer is null or the data type is invalid.
SDFIO_ERR_RANGEThe size cannot be represented in a size_t.

◆ sdfio_heights_row_size()

sdfio_status sdfio_heights_row_size ( const sdfio_header * header,
sdfio_data_type type,
size_t * bytes )

Returns the size in bytes of a buffer for one row of heights in a type, for sdfio_decode_heights() and sdfio_encode_heights() of one row of the data area.

Parameters
[in]headerThe header of the file.
typeThe type of the heights: SDFIO_TYPE_FLOAT or SDFIO_TYPE_DOUBLE.
[out]bytesThe size, which is 0 for a row without columns.
Return values
SDFIO_ERR_ARGUMENTA pointer is null or the type is not SDFIO_TYPE_FLOAT or SDFIO_TYPE_DOUBLE.
SDFIO_ERR_RANGEThe size cannot be represented in a size_t.
Examples
read_stream.c.

◆ sdfio_heights_size()

sdfio_status sdfio_heights_size ( const sdfio_header * header,
sdfio_data_type type,
size_t * bytes )

Returns the size in bytes of a buffer for the whole matrix of heights in a type, for sdfio_read_heights() and sdfio_write_heights().

The caller allocates it.

Parameters
[in]headerThe header of the file.
typeThe type of the heights: SDFIO_TYPE_FLOAT or SDFIO_TYPE_DOUBLE.
[out]bytesThe size, which is 0 for an empty matrix.
Return values
SDFIO_ERR_ARGUMENTA pointer is null or the type is not SDFIO_TYPE_FLOAT or SDFIO_TYPE_DOUBLE.
SDFIO_ERR_RANGEThe size cannot be represented in a size_t.
Examples
read_heights.c.