feat: add periodic image saving

This commit is contained in:
Noa Aarts 2024-10-11 16:05:16 +02:00
parent 6da19152ca
commit 0502f3dacb
Signed by: noa
GPG key ID: 1850932741EFF672
6 changed files with 1085 additions and 6 deletions

View file

@ -1,5 +1,7 @@
use std::cell::SyncUnsafeCell;
use image::{DynamicImage, GenericImage, GenericImageView, ImageBuffer, Pixel, Rgb, Rgba};
use crate::Coordinate;
pub trait Grid<I, V> {
@ -63,6 +65,21 @@ impl<T> Grid<Coordinate, T> for Flut<T> {
}
}
impl GenericImageView for Flut<u32> {
type Pixel = Rgb<u8>;
fn dimensions(&self) -> (u32, u32) {
let (x, y) = self.get_size();
(x as u32, y as u32)
}
fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel {
let pixel = self.get_unchecked(x as u16, y as u16);
let [r, g, b, _a] = pixel.to_be_bytes();
Rgb::from([r, g, b])
}
}
#[cfg(test)]
#[allow(clippy::needless_return)]
mod tests {