62 std::span<const uint8_t> bytes)
65 if (!result || result->byte_size() != bytes.size()) {
69 std::memcpy(result->data(), bytes.data(), bytes.size());
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);
ImageFormat
User-friendly image format enum.
size_t element_count() const
Number of pixel elements (not bytes), dispatched on variant.
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.
static std::optional< ImageData > from_bytes(uint32_t width, uint32_t height, uint32_t channels, ImageFormat format, std::span< const uint8_t > bytes)
Build an ImageData from raw pixel bytes in format's layout.
bool is_consistent() const
Check that the active variant matches the declared format.
Raw image data loaded from file or read back from a GPU image.