add options to disable steps
All checks were successful
Rust / build (pull_request) Successful in 6m29s

This commit is contained in:
Vinzenz Schroeter 2025-02-28 18:49:29 +01:00
parent f566f0959b
commit b6f019ba4e
2 changed files with 36 additions and 8 deletions

View file

@ -121,4 +121,20 @@ pub struct StreamScreenOptions {
help = "Show mouse pointer in video feed"
)]
pub pointer: bool,
#[arg(long, help = "Disable histogram correction")]
pub no_hist: bool,
#[arg(long, help = "Disable blur")]
pub no_blur: bool,
#[arg(long, help = "Disable sharpening")]
pub no_sharp: bool,
#[arg(
long,
help = "Disable dithering.
Brightness will be adjusted so that around half of the pixels are on."
)]
pub no_dither: bool,
}

View file

@ -10,9 +10,7 @@ use scap::{
frame::convert_bgra_to_rgb,
frame::Frame,
};
use servicepoint::{
Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH,
};
use servicepoint::{Bitmap, Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH};
use std::time::Duration;
pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
@ -27,15 +25,29 @@ pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
loop {
let mut frame = get_next_frame(&capturer);
histogram_correction(&mut frame);
if !options.no_hist {
histogram_correction(&mut frame);
}
let mut orig = frame.clone();
blur(&orig, &mut frame);
std::mem::swap(&mut frame, &mut orig);
sharpen(&orig, &mut frame);
if !options.no_blur {
blur(&orig, &mut frame);
std::mem::swap(&mut frame, &mut orig);
}
let bitmap = ostromoukhov_dither(frame, u8::MAX / 2);
if !options.no_sharp {
sharpen(&orig, &mut frame);
std::mem::swap(&mut frame, &mut orig);
}
let bitmap = if options.no_dither {
let cutoff = median_brightness(&orig);
let bits = orig.iter().map(move |x| x > &cutoff).collect();
Bitmap::from_bitvec(orig.width() as usize, bits)
} else {
ostromoukhov_dither(orig, u8::MAX / 2)
};
connection
.send(Command::BitmapLinearWin(