pi-frame-server/src/main.rs

43 lines
962 B
Rust
Raw Normal View History

2024-07-02 15:57:29 +00:00
pub mod display;
2024-06-29 16:55:37 +00:00
pub mod imageproc;
2024-07-02 15:57:29 +00:00
use crate::display::DisplayWrapper;
use crate::imageproc::{Ditherer, EInkBuffer, NNDither};
use clap::{Parser, Subcommand};
use image::RgbImage;
/// Display images over
2024-06-29 16:55:37 +00:00
#[derive(Debug, Parser)]
#[command(version, about)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Debug, Subcommand)]
enum Command {
/// Load a single image
2024-07-02 15:57:29 +00:00
Show,
2024-06-29 16:55:37 +00:00
/// Start the HTTP sever
Serve,
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
println!("CLI {cli:?}");
2024-07-02 15:57:29 +00:00
if let Command::Show = cli.command {
let img: RgbImage = image::io::Reader::open("myimage.png")?.decode()?.into();
let mut display = DisplayWrapper::new()?;
let mut eink_buf = EInkBuffer::new(800, 480);
let dither = NNDither {};
dither.dither(&img, &mut eink_buf);
let raw_buf = eink_buf.into_display_buffer();
display.display(&raw_buf)?;
2024-06-29 16:55:37 +00:00
}
Ok(())
2024-06-24 13:29:59 +00:00
}