Remove all dependencies on showbits-common

This commit is contained in:
Joscha 2025-03-01 23:23:43 +01:00
parent de7ae63a5e
commit 6e6dfb2b66
8 changed files with 26 additions and 28 deletions

View file

@ -8,7 +8,8 @@ use escpos::{
utils::{GS, PageCode, Protocol},
};
use image::{Rgba, RgbaImage};
use showbits_common::color;
use crate::color;
pub struct Printer {
printer: Option<EPrinter<FileDriver>>,
@ -143,7 +144,7 @@ impl Printer {
/// Instead of doing the physically accurate thing, I do what makes the most
/// sense visually.
fn pixel_to_bit(pixel: Rgba<u8>) -> bool {
let color = color::from_image_color(pixel);
let color = color::image_to_palette(pixel);
let avg = (color.red + color.green + color.blue) / 3.0;
avg < 0.5 // true == black
}