diff --git a/src/dither.rs b/src/dither.rs index 33a55ee..7ea316a 100644 --- a/src/dither.rs +++ b/src/dither.rs @@ -39,8 +39,8 @@ pub enum ProcessingError { /// Buffer to be sent to the ``EInk`` display. #[derive(Debug)] pub struct DitheredImage { - buf: ImageBuffer, Vec>, - palette: Vec, + pub buf: ImageBuffer, Vec>, + pub palette: Vec, } impl DitheredImage { @@ -86,8 +86,7 @@ pub trait Ditherer { fn dither(&mut self, img: &RgbImage, output: &mut DitheredImage); } -/// Find the closest approximate palette color to the given sRGB value. -/// This uses euclidian distance in linear space. +/// Find the closest approximate palette color fn nearest_neighbor(input_color: Lab, palette: &[Lab]) -> (u8, Lab) { let (nearest, _, color_diff) = palette .iter() @@ -95,7 +94,7 @@ fn nearest_neighbor(input_color: Lab, palette: &[Lab]) -> (u8, Lab) { .map(|(idx, p_color)| { ( idx, - input_color.difference(*p_color), + input_color.difference(*p_color), // this is CIEDIE2000 based and highly accurate. input_color - *p_color, ) }) @@ -199,7 +198,7 @@ static STUKI_DITHER_POINTS: &[DiffusionPoint] = &[ pub type DiffusionMatrix<'a> = &'a [DiffusionPoint]; #[derive(Debug)] -pub struct ErrorDiffusion<'a>(&'a [DiffusionPoint]); +pub struct ErrorDiffusion<'a>(DiffusionMatrix<'a>); impl<'a> ErrorDiffusion<'a> { #[must_use]