Compare commits
2 commits
43c53555d9
...
cc29d5226b
Author | SHA1 | Date | |
---|---|---|---|
cc29d5226b | |||
7020006e89 |
2 changed files with 4 additions and 16 deletions
|
@ -13,7 +13,7 @@ use std::{
|
|||
|
||||
use bracket_color::prelude::{HSV, RGB};
|
||||
use clap::{Parser, Subcommand};
|
||||
use image::{imageops::FilterType, io::Reader as ImageReader, Pixel, Rgb, RgbImage};
|
||||
use image::{Pixel, Rgb, RgbImage};
|
||||
use rand::Rng;
|
||||
|
||||
use splink_client::{send_frame, Layout};
|
||||
|
@ -193,10 +193,7 @@ fn main() -> anyhow::Result<()> {
|
|||
send_frame(&socket, layout, frame_num, &image)?;
|
||||
}
|
||||
Action::Image { path } => {
|
||||
let image = ImageReader::open(path)?
|
||||
.decode()?
|
||||
.resize_to_fill(layout.width_px(), layout.height_px(), FilterType::Gaussian)
|
||||
.into_rgb8();
|
||||
let image = RgbImage::new(layout.width_px(), layout.height_px());
|
||||
let frame_num: u32 = rand::thread_rng().gen();
|
||||
send_frame(&socket, layout, frame_num, &image)?;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,6 @@ pub struct Strandifier<'a> {
|
|||
pixels_remaining: u32,
|
||||
next_x: u32,
|
||||
next_y: u32,
|
||||
|
||||
offset_x: u32,
|
||||
offset_y: u32,
|
||||
}
|
||||
|
||||
impl<'a> Strandifier<'a> {
|
||||
|
@ -44,7 +41,7 @@ impl<'a> Strandifier<'a> {
|
|||
image: &'a RgbImage,
|
||||
strand_num: u32,
|
||||
) -> Result<Self, StrandifierError> {
|
||||
if layout.width_px() < image.width() || layout.height_px() < image.height() {
|
||||
if layout.width_px() != image.width() || layout.height_px() != image.height() {
|
||||
return Err(StrandifierError::WrongDimensions);
|
||||
}
|
||||
|
||||
|
@ -58,9 +55,6 @@ impl<'a> Strandifier<'a> {
|
|||
let first_x = panel_x * layout.gang_len;
|
||||
let first_y = panel_y * layout.num_gangs;
|
||||
|
||||
let offset_x = (layout.width_px() - image.width()) / 2;
|
||||
let offset_y = (layout.height_px() - image.height()) / 2;
|
||||
|
||||
Ok(Self {
|
||||
layout,
|
||||
image,
|
||||
|
@ -68,9 +62,6 @@ impl<'a> Strandifier<'a> {
|
|||
pixels_remaining: layout.strand_len(),
|
||||
next_x: first_x,
|
||||
next_y: first_y,
|
||||
|
||||
offset_x,
|
||||
offset_y,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +98,7 @@ impl<'a> Iterator for Strandifier<'a> {
|
|||
}
|
||||
self.pixels_remaining -= 1;
|
||||
|
||||
Some(*self.image.get_pixel(x + self.offset_x, y + self.offset_y))
|
||||
Some(*self.image.get_pixel(x, y))
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
|
|
Loading…
Reference in a new issue