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

◆ from_bytes()

std::optional< ImageData > MayaFlux::Kakshya::ImageData::from_bytes ( uint32_t  width,
uint32_t  height,
uint32_t  channels,
ImageFormat  format,
std::span< const uint8_t >  bytes 
)
static

Build an ImageData from raw pixel bytes in format's layout.

Allocates as allocate() does and copies bytes in.

Returns
The populated ImageData, or nullopt when allocate() would fail or bytes is not exactly width * height * channels elements.

Definition at line 57 of file ImageData.cpp.

63{
64 auto result = allocate(width, height, channels, format);
65 if (!result || result->byte_size() != bytes.size()) {
66 return std::nullopt;
67 }
68
69 std::memcpy(result->data(), bytes.data(), bytes.size());
70 return result;
71}
static std::optional< ImageData > allocate(uint32_t width, uint32_t height, uint32_t channels, ImageFormat format)
Allocate zeroed pixel storage of the variant format calls for.
Definition ImageData.cpp:5

References allocate(), channels, format, height, and width.

Referenced by MayaFlux::Kriya::Chimera::feed(), and MayaFlux::Buffers::DataReadProcessor::read_host_pixels().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: