pub mod ops;
pub mod rgb;
pub use crate::img::ops::ImgOp;
pub trait PixelType: Copy + Send + Sync {
fn from(c: &[f32; 3]) -> Self;
}
pub struct Image<P: PixelType> {
raw: Vec<P>,
w: usize,
h: usize,
}
impl<P: PixelType> Image<P> {
pub fn new(w: usize, h: usize) -> Self {
let data = vec![P::from(&[0.; 3]); w * h];
Image { raw: data, w, h }
}
pub fn shape(&self) -> (usize, usize) {
(self.w, self.h)
}
pub fn data(&self) -> &[P] {
&self.raw
}
pub fn data_mut(&mut self) -> &mut [P] {
&mut self.raw
}
}