use std::fmt::Display;
use vbox_raw::sys_lib as raw;
#[derive(Debug, Eq, PartialEq)]
pub enum BitmapFormat {
Opaque,
BGR,
BGR0,
BGRA,
RGBA,
PNG,
JPEG,
}
impl Into<u32> for BitmapFormat {
fn into(self) -> u32 {
match self {
BitmapFormat::Opaque => raw::BitmapFormat_BitmapFormat_Opaque,
BitmapFormat::BGR => raw::BitmapFormat_BitmapFormat_BGR,
BitmapFormat::BGR0 => raw::BitmapFormat_BitmapFormat_BGR0,
BitmapFormat::BGRA => raw::BitmapFormat_BitmapFormat_BGRA,
BitmapFormat::RGBA => raw::BitmapFormat_BitmapFormat_RGBA,
BitmapFormat::PNG => raw::BitmapFormat_BitmapFormat_PNG,
BitmapFormat::JPEG => raw::BitmapFormat_BitmapFormat_JPEG,
}
}
}
impl From<u32> for BitmapFormat {
fn from(value: u32) -> Self {
match value {
raw::BitmapFormat_BitmapFormat_BGR => BitmapFormat::BGR,
raw::BitmapFormat_BitmapFormat_BGR0 => BitmapFormat::BGR0,
raw::BitmapFormat_BitmapFormat_BGRA => BitmapFormat::BGRA,
raw::BitmapFormat_BitmapFormat_RGBA => BitmapFormat::RGBA,
raw::BitmapFormat_BitmapFormat_PNG => BitmapFormat::PNG,
raw::BitmapFormat_BitmapFormat_JPEG => BitmapFormat::JPEG,
_ => BitmapFormat::Opaque,
}
}
}
impl Display for BitmapFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", format!("{:?}", self))
}
}