#[cfg(all(
any(feature = "std", feature = "alloc"),
any(
feature = "gbr",
feature = "gray",
feature = "rgb",
feature = "v210",
feature = "y2xx",
feature = "yuv-444-packed",
feature = "yuv-packed",
feature = "yuv-planar",
feature = "yuv-semi-planar",
feature = "yuva",
),
))]
#[cfg_attr(not(tarpaulin), inline(always))]
pub(crate) fn expand_rgb_to_rgba_row(rgb: &[u8], rgba_out: &mut [u8], width: usize) {
debug_assert!(rgb.len() >= width * 3, "rgb row too short");
debug_assert!(rgba_out.len() >= width * 4, "rgba_out row too short");
for (rgb_px, rgba_px) in rgb[..width * 3]
.chunks_exact(3)
.zip(rgba_out[..width * 4].chunks_exact_mut(4))
{
rgba_px[0] = rgb_px[0];
rgba_px[1] = rgb_px[1];
rgba_px[2] = rgb_px[2];
rgba_px[3] = 0xFF;
}
}
#[cfg(all(
any(feature = "std", feature = "alloc"),
any(
feature = "gbr",
feature = "gray",
feature = "rgb",
feature = "v210",
feature = "y2xx",
feature = "yuv-444-packed",
feature = "yuv-planar",
feature = "yuva",
),
))]
#[cfg_attr(not(tarpaulin), inline(always))]
pub(crate) fn expand_rgb_u16_to_rgba_u16_row<const BITS: u32>(
rgb: &[u16],
rgba_out: &mut [u16],
width: usize,
) {
const {
assert!(BITS > 0 && BITS <= 16);
}
let rgb_len = width.checked_mul(3).expect("rgb row length overflow");
let rgba_len = width.checked_mul(4).expect("rgba row length overflow");
debug_assert!(rgb.len() >= rgb_len, "rgb row too short");
debug_assert!(rgba_out.len() >= rgba_len, "rgba_out row too short");
let alpha_max: u16 = ((1u32 << BITS) - 1) as u16;
for (rgb_px, rgba_px) in rgb[..rgb_len]
.chunks_exact(3)
.zip(rgba_out[..rgba_len].chunks_exact_mut(4))
{
rgba_px[0] = rgb_px[0];
rgba_px[1] = rgb_px[1];
rgba_px[2] = rgb_px[2];
rgba_px[3] = alpha_max;
}
}