MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ is_consistent()

bool MayaFlux::Kakshya::ImageData::is_consistent ( ) const

Check that the active variant matches the declared format.

Callers producing ImageData should invoke this to validate before handing the data to downstream consumers.

Definition at line 73 of file ImageData.cpp.

74{
75 using F = ImageFormat;
76
77 const bool has_u8 = std::holds_alternative<std::vector<uint8_t>>(pixels);
78 const bool has_u16 = std::holds_alternative<std::vector<uint16_t>>(pixels);
79 const bool has_f32 = std::holds_alternative<std::vector<float>>(pixels);
80
81 switch (format) {
82 case F::R8:
83 case F::RG8:
84 case F::RGBA8:
85 case F::RGBA8_SRGB:
86 case F::BGRA8:
87 case F::BGRA8_SRGB:
88 return has_u8;
89
90 case F::R16:
91 case F::RG16:
92 case F::RGBA16:
93 return has_u16;
94
95 case F::R16F:
96 case F::RG16F:
97 case F::RGBA16F:
98 return has_u16;
99
100 case F::R32F:
101 case F::RG32F:
102 case F::RGBA32F:
103 return has_f32;
104
105 default:
106 return false;
107 }
108}
ImageFormat
User-friendly image format enum.
Definition ImageData.hpp:12

References format, and pixels.

Referenced by MayaFlux::IO::EXRWriter::write(), and MayaFlux::IO::STBImageWriter::write().

+ Here is the caller graph for this function: