18 spdlog::error(
"convert_RGBA_F32_to_RGBA_U8: Input is invalid or not RGBA_F32");
24 OIIO::ImageBuf src_buf(src_spec,
const_cast<float*
>(input.
m_data.data()));
28 OIIO::ImageBuf dst_buf(dst_spec);
31 if (!OIIO::ImageBufAlgo::copy(dst_buf, src_buf)) {
32 spdlog::error(
"convert_RGBA_F32_to_RGBA_U8: OIIO conversion failed");
37 auto result { std::make_unique<Common::ImageRegion>() };
38 result->m_x = input.
x();
39 result->m_y = input.
y();
40 result->m_width = input.
width();
41 result->m_height = input.
height();
42 result->m_channels = input.
channels();
44 const size_t total_elements {
static_cast<size_t>(input.
width()) * input.
height() * input.
channels() };
45 result->m_data.resize(total_elements);
47 if (!dst_buf.get_pixels(OIIO::ROI::All(), OIIO::TypeDesc::UINT8, result->m_data.data())) {
48 spdlog::error(
"convert_RGBA_F32_to_RGBA_U8: Failed to extract U8 pixels from OIIO buffer");