#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitImage {
pub width: u32,
pub height: u32,
pub row_bytes: usize,
pub bits: Vec<u8>,
}
impl BitImage {
#[must_use]
pub fn pixel(&self, x: u32, y: u32) -> bool {
let Ok(row) = usize::try_from(y) else {
return false;
};
let Ok(col) = usize::try_from(x) else {
return false;
};
let Some(byte) = self.bits.get(row * self.row_bytes + col / 8) else {
return false;
};
(byte >> (7 - (col % 8))) & 1 == 1
}
}