WIP: Pixel writing

This commit is contained in:
Jonas Zeunert
2024-12-29 18:05:18 +01:00
parent 1c98331f59
commit 97c7f3d6b1
2 changed files with 17 additions and 2 deletions

View File

@@ -4,5 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
address = "0.11.0"
clap = { version = "4.5.23", features = ["derive"] }
image = "0.25.5"
tokio = "1.42.0"

View File

@@ -1,13 +1,20 @@
use address::Host;
use std::path::PathBuf;
use image::{ImageReader, RgbImage};
use image::{ImageReader, Rgb};
use clap::Parser;
type Pixel<'a> = (u32, u32, &'a Rgb<u8>);
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
image_path: PathBuf,
addr: Host,
#[arg(short, long, default_value_t = 1234)]
port: u16,
}
fn main() {
@@ -20,8 +27,14 @@ fn main() {
Err(err) => panic!("Error reading image! {err}"),
};
println!("{:?}", &image);
let rgb_image = image.into_rgb8();
for pixel in rgb_image.enumerate_pixels() {
write_pixel(pixel);
}
//println!("{:?}", &image);
}
fn write_pixel(pixel: Pixel) {}
fn parse_image(path: &PathBuf) -> Result<image::DynamicImage, image::error::ImageError> {
ImageReader::open(path)?.with_guessed_format()?.decode()