Dtype

class Dtype

class to define the data type of the pixels

Note

only native endianess is supported

Public Types

enum TypeIndex

Values:

enumerator INT8
enumerator UINT8
enumerator INT16
enumerator UINT16
enumerator INT32
enumerator UINT32
enumerator INT64
enumerator UINT64
enumerator FLOAT
enumerator DOUBLE
enumerator ERROR
enumerator NONE

Public Functions

uint8_t bitdepth() const

Get the bitdepth of the data type.

Returns:

bitdepth

size_t bytes() const

Get the number of bytes of the data type.

inline std::string format_descr() const
inline std::string numpy_descr() const
explicit Dtype(const std::type_info &t)

Construct a DType object from a type_info object.

Note

supported types are: int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double

Note

the type_info object is obtained using typeid (e.g. typeid(int))

Parameters:

t – type_info object

Throws:

runtime_error – if the type is not supported

explicit Dtype(std::string_view sv)

Construct a DType object from a string.

Note

example strings: “<i4”, “u8”, “f4”

Note

the endianess is checked and only native endianess is supported

Parameters:

sv – string_view

Throws:

runtime_error – if the type is not supported

Dtype(Dtype::TypeIndex ti)

Construct a DType object from a TypeIndex.

Parameters:

ti – TypeIndex

bool operator==(const Dtype &other) const noexcept
bool operator!=(const Dtype &other) const noexcept
bool operator==(const std::type_info &t) const
bool operator!=(const std::type_info &t) const
std::string to_string() const

Get the string representation of the data type.

Returns:

string representation

inline void set_type(Dtype::TypeIndex ti)

Public Static Functions

static Dtype from_bitdepth(uint8_t bitdepth)