use super::Format;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Mode {
L,
Rgb,
Rgba,
}
const _: () = crate::send_sync::<Mode>();
impl Mode {
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::L => "L",
Self::Rgb => "RGB",
Self::Rgba => "RGBA",
}
}
#[must_use]
pub const fn bytes_per_pixel(self) -> u64 {
match self {
Self::L => 1,
Self::Rgb => 3,
Self::Rgba => 4,
}
}
}
impl Format {
#[must_use]
pub const fn mode(self) -> Mode {
if let Some(layout) = crate::tierb::layout(self) {
return if layout.channels == 4 {
Mode::Rgba
} else {
Mode::Rgb
};
}
match self {
Self::Bc4 => Mode::L,
Self::Rgb24 | Self::Rgb565 | Self::Bgr24 | Self::R8 | Self::Bc5 | Self::Bc6h => {
Mode::Rgb
}
_ => Mode::Rgba,
}
}
}