use crate::{ColorFormat, PixelFormat};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CropWindow {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum OutputBitDepth {
Bit1White,
Bit1Black,
U8,
U10,
U16 { shift_bits: u8 },
I16 { shift_bits: u8 },
F16,
I32 { shift_bits: u8 },
F32 {
mantissa_length: u8,
exponent_bias: i8,
},
Rgb555,
Rgb101010,
Rgb565,
}
impl OutputBitDepth {
#[must_use]
pub const fn from_header_fields(
code: u8,
shift_bits: u8,
mantissa_length: u8,
exponent_bias: i8,
) -> Option<Self> {
match code {
0 => Some(Self::Bit1White),
1 => Some(Self::U8),
2 => Some(Self::U16 { shift_bits }),
3 => Some(Self::I16 { shift_bits }),
4 => Some(Self::F16),
6 => Some(Self::I32 { shift_bits }),
7 => Some(Self::F32 {
mantissa_length,
exponent_bias,
}),
8 => Some(Self::Rgb555),
9 => Some(Self::U10),
10 => Some(Self::Rgb565),
15 => Some(Self::Bit1Black),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct AlphaFormatRequest {
pub bit_depth: OutputBitDepth,
pub scaled: bool,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct OutputFormatRequest {
pub internal_color: ColorFormat,
pub output_color: ColorFormat,
pub bit_depth: OutputBitDepth,
pub pixel_format: PixelFormat,
pub scaled: bool,
pub alpha_format: Option<AlphaFormatRequest>,
pub red_blue_not_swapped: bool,
pub premultiply_alpha: bool,
pub crop: CropWindow,
}