i didnt say im fancy fixing it
All checks were successful
Rust / build (pull_request) Successful in 8m19s

there is an off by one somewhere _shrug_
This commit is contained in:
Vinzenz Schroeter 2025-05-04 16:19:25 +02:00
parent 6a5af6b4f4
commit 57e784c6e9
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,7 @@
//! Based on https://github.com/WarkerAnhaltRanger/CCCB_Ledwand
use image::GrayImage;
use log::error;
use servicepoint::{Bitmap, DisplayBitVec, PIXEL_HEIGHT};
type GrayHistogram = [usize; 256];
@ -217,8 +218,15 @@ fn ostromoukhov_dither_pixel(
destination.set(position, destination_value);
let mut diffuse = |to: usize, mat: i16| {
let diffuse_value = source[to] as i16 + mat;
match source.get(to) {
None => {
error!("ostromoukhov_dither_pixel - invalid index {to}");
}
Some(val) => {
let diffuse_value = *val as i16 + mat;
source[to] = diffuse_value.clamp(u8::MIN.into(), u8::MAX.into()) as u8;
}
};
};
let lookup = if destination_value {

View file

@ -7,7 +7,7 @@ use crate::{
};
use clap::Parser;
use log::debug;
use servicepoint::{Brightness, HardResetCommand, UdpSocketExt};
use servicepoint::{Brightness, HardResetCommand};
mod brightness;
mod cli;