9#include "_cexports/c_img.h"
12#include "exception.hpp"
33 return DataType(dataTypeDescriptor);
53 return DataType(8 | CExports::DT_Signed);
93 return DataType(16 | CExports::DT_Signed);
113 return DataType(32 | CExports::DT_Signed);
133 return DataType(64 | CExports::DT_Signed);
143 return DataType(32 | CExports::DT_Float | CExports::DT_Signed);
153 return DataType(64 | CExports::DT_Float | CExports::DT_Signed);
172 template <
typename T>
176 "CVB: Unsupported image plane data type!");
177 static_assert((1 << 8) == CExports::DT_Signed,
"CVB: DT_Signed does not match!");
178 static_assert((1 << 9) == CExports::DT_Float,
"CVB: DT_Float does not match!");
180 CExports::cvbdatatype_t nativeDescriptor =
sizeof(T) * 8
185 return DataType(nativeDescriptor);
199 template <
template <
class>
class T,
class ACTION,
class... CTORARGS>
214 T<std::uint16_t> t{std::forward<CTORARGS>(args)...};
219 T<std::uint32_t> t{std::forward<CTORARGS>(args)...};
224 T<std::uint64_t> t{std::forward<CTORARGS>(args)...};
239 T<std::int8_t> t{std::forward<CTORARGS>(args)...};
244 T<std::int16_t> t{std::forward<CTORARGS>(args)...};
249 T<std::int32_t> t{std::forward<CTORARGS>(args)...};
254 T<std::int64_t> t{std::forward<CTORARGS>(args)...};
269 T<float> t{std::forward<CTORARGS>(args)...};
274 T<double> t{std::forward<CTORARGS>(args)...};
284 throw std::runtime_error(
"Could not match native data type");
300 "CVB: T must be integer or floating point");
314 return dataTypeDescriptor_;
324 return dataTypeDescriptor_ & 0xFF;
346 return (dataTypeDescriptor_ & CExports::DT_Float) != 0;
356 return (dataTypeDescriptor_ & CExports::DT_Signed) != 0 && !
IsFloat();
366 return (dataTypeDescriptor_ & 0xB00) == 0;
376 return (dataTypeDescriptor_ & CExports::DT_Signed) != 0;
386 return (dataTypeDescriptor_ & CExports::DT_Overlay) != 0;
402 return (dataTypeDescriptor_ & CExports::DT_ComplexPacked) != 0;
426 CExports::cvbval_t min = 0;
427 CExports::cvbval_t max = 0;
428 CVB_CALL_CAPI(
GetDatatypeMinMaxVal(
static_cast<CExports::cvbdatatype_t
>(dataTypeDescriptor_), min, max));
429 return static_cast<double>(min);
454 CExports::cvbval_t min = 0;
455 CExports::cvbval_t max = 0;
456 CVB_CALL_CAPI(
GetDatatypeMinMaxVal(
static_cast<CExports::cvbdatatype_t
>(dataTypeDescriptor_), min, max));
457 return static_cast<double>(max);
506 if (
IsFloat() && dataType.IsFloat())
508 return dataTypeDescriptor_ == dataType.dataTypeDescriptor_;
519 return !(*
this == dataType);
526 : dataTypeDescriptor_(dataTypeDescriptor)
530 int dataTypeDescriptor_ = 0;
Data type description for an image plane.
Definition data_type.hpp:23
int BytesPerPixel() const noexcept
Number of bytes occupied by each pixel.
Definition data_type.hpp:332
static DataType Int64BppSigned() noexcept
Represents 64-bit signed integer pixels.
Definition data_type.hpp:131
static DataType Int12BppUnsigned() noexcept
Represents 12-bit unsigned integer pixels.
Definition data_type.hpp:71
double MinVal() const noexcept
Gets the minimum pixel value that fits this data type.
Definition data_type.hpp:410
static DataType Int16BppUnsigned() noexcept
Represents 16-bit unsigned integer pixels.
Definition data_type.hpp:81
bool HasOverlayBit() const noexcept
Gets whether bit 0 of the pixels of the plane are being used as an overlay indicator bit.
Definition data_type.hpp:384
int BitsPerPixel() const noexcept
Number of actually valid bits per pixel.
Definition data_type.hpp:322
bool IsSigned() const noexcept
Gets whether the pixels of the plane have signed values.
Definition data_type.hpp:374
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition data_type.hpp:312
bool IsSignedInteger() const noexcept
Gets whether the pixels of the plane have signed integer values.
Definition data_type.hpp:354
static DataType Int8BppUnsigned() noexcept
Represents 8-bit unsigned integer pixels (bytes).
Definition data_type.hpp:41
bool operator!=(const DataType &dataType) const noexcept
Compares to an other data type.
Definition data_type.hpp:517
bool Matches() const noexcept
Gets whether the type T matches this data type.
Definition data_type.hpp:297
bool IsUnsignedInteger() const noexcept
Gets whether the pixels of the plane have unsigned integer values.
Definition data_type.hpp:364
static DataType Int32BppUnsigned() noexcept
Represents 32-bit unsigned integer pixels.
Definition data_type.hpp:101
PixelDataType NumericType() const noexcept
Returns the basic numeric type of the pixels.
Definition data_type.hpp:466
static DataType Int32BppSigned() noexcept
Represents 32-bit signed integer pixels.
Definition data_type.hpp:111
bool operator==(const DataType &dataType) const noexcept
Compares to an other data type.
Definition data_type.hpp:504
static DataType FromNativeType() noexcept
Construct a data type descriptor from one of the native data type value equivalents.
Definition data_type.hpp:173
static DataType Int16BppSigned() noexcept
Represents 16-bit signed integer pixels.
Definition data_type.hpp:91
bool IsFloat() const noexcept
Gets whether the pixels of the plane have floating point values.
Definition data_type.hpp:343
auto CallWithInstanceOf(ACTION action, CTORARGS... args) const -> decltype(action(T< int >{std::forward< CTORARGS >(args)...}))
Calls action with T instance of native data type this value represents.
Definition data_type.hpp:200
static DataType Int8BppSigned() noexcept
Represents 8-bit signed integer pixels.
Definition data_type.hpp:51
static DataType FromNativeDescriptor(int dataTypeDescriptor) noexcept
Construct a data type descriptor from one of the native library's descriptor values.
Definition data_type.hpp:31
static DataType Float32Bpp() noexcept
Represents single precision (32-bit) floating point pixels.
Definition data_type.hpp:141
static DataType Int10BppUnsigned() noexcept
Represents 10-bit unsigned integer pixels.
Definition data_type.hpp:61
static DataType Int64BppUnsigned() noexcept
Represents 64-bit unsigned integer pixels.
Definition data_type.hpp:121
static DataType Float64Bpp() noexcept
Represents double precision (64-bit) floating point pixels.
Definition data_type.hpp:151
double MaxVal() const noexcept
Gets the maximum pixel value that fits this data type.
Definition data_type.hpp:438
double UndefinedVal() const noexcept
Get the undefined value for this data type.
Definition data_type.hpp:489
bool IsComplexPacked() const noexcept
Indicates whether or not the plane contains a complex packed image format.
Definition data_type.hpp:400
cvbbool_t GetDatatypeMinMaxVal(cvbdatatype_t Datatype, cvbval_t &MinVal, cvbval_t &MaxVal)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
PixelDataType
Defines the numeric data type of one pixel.
Definition global.hpp:149
@ UInt
Definition global.hpp:159
@ Int
Definition global.hpp:163
@ Float
Definition global.hpp:167
@ ComplexPackedFloat
Definition global.hpp:171
@ Undefined
Definition global.hpp:155