diff --git a/build.sh b/build.sh index 2c09499..711ed94 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set +x -cross build --target aarch64-unknown-linux-gnu --release -rsync -aczP target/aarch64-unknown-linux-gnu/release/pi-frame-server 192.168.0.186: +cross build --target aarch64-unknown-linux-gnu --release --features eink +rsync -aczP target/aarch64-unknown-linux-gnu/release/pi-frame-server 192.168.0.185: # scp target/aarch64-unknown-linux-gnu/debug/pi-frame-server 192.168.0.186: -ssh 192.168.0.186 ./pi-frame-server load +ssh 192.168.0.185 ./pi-frame-server show diff --git a/src/imageproc.rs b/src/imageproc.rs index 16c353b..ac5f95f 100644 --- a/src/imageproc.rs +++ b/src/imageproc.rs @@ -141,7 +141,7 @@ pub fn nearest_neighbor(input_color: Lab) -> (DisplayColor, Lab) { .enumerate() .map(|(idx, p_color)| { let c: Lab = (*p_color).into_color(); - (idx, input_color.distance_squared(c), input_color - c) + (idx, input_color.difference(c), input_color - c) }) .min_by(|(_, a, _), (_, b, _)| a.total_cmp(b)) .expect("could not find a color"); @@ -207,6 +207,14 @@ const FLOYD_STEINBERG: [DiffusionPoint; 4] = [ DiffusionPoint::new(0, 1, 5.0 / 16.0), DiffusionPoint::new(1, 1, 1.0 / 16.0), ]; +const ATKINSON_DITHER: [DiffusionPoint; 6] = [ + DiffusionPoint::new(1, 0, 1.0/8.0), + DiffusionPoint::new(2, 0, 1.0/8.0), + DiffusionPoint::new(-1, 1, 1.0/8.0), + DiffusionPoint::new(0, 1, 1.0/8.0), + DiffusionPoint::new(1, 1, 1.0/8.0), + DiffusionPoint::new(0, 2, 1.0/8.0), +]; impl Ditherer for FloydSteinbergDither { fn dither(&mut self, img: &RgbImage, output: &mut EInkBuffer) { @@ -227,7 +235,7 @@ impl Ditherer for FloydSteinbergDither { // set the color in the output buffer. output.0[index] = nearest; // take the error, and propagate it. - for point in FLOYD_STEINBERG { + for point in ATKINSON_DITHER { let Some(target_x) = x.checked_add_signed(point.xshift) else { continue; }; diff --git a/src/main.rs b/src/main.rs index 3dce30d..4cba245 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ fn main() -> anyhow::Result<()> { let mut display = Wrapper::new()?; let mut eink_buf = EInkBuffer::new(800, 480); - let mut dither = NNDither{}; + let mut dither = FloydSteinbergDither{}; dither.dither(&img, &mut eink_buf); let raw_buf = eink_buf.into_display_buffer();