add options to disable steps
All checks were successful
Rust / build (pull_request) Successful in 6m29s
All checks were successful
Rust / build (pull_request) Successful in 6m29s
This commit is contained in:
parent
f566f0959b
commit
b6f019ba4e
16
src/cli.rs
16
src/cli.rs
|
@ -121,4 +121,20 @@ pub struct StreamScreenOptions {
|
||||||
help = "Show mouse pointer in video feed"
|
help = "Show mouse pointer in video feed"
|
||||||
)]
|
)]
|
||||||
pub pointer: bool,
|
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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,7 @@ use scap::{
|
||||||
frame::convert_bgra_to_rgb,
|
frame::convert_bgra_to_rgb,
|
||||||
frame::Frame,
|
frame::Frame,
|
||||||
};
|
};
|
||||||
use servicepoint::{
|
use servicepoint::{Bitmap, Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH};
|
||||||
Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH,
|
|
||||||
};
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
||||||
|
@ -27,15 +25,29 @@ pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
||||||
loop {
|
loop {
|
||||||
let mut frame = get_next_frame(&capturer);
|
let mut frame = get_next_frame(&capturer);
|
||||||
|
|
||||||
histogram_correction(&mut frame);
|
if !options.no_hist {
|
||||||
|
histogram_correction(&mut frame);
|
||||||
|
}
|
||||||
|
|
||||||
let mut orig = frame.clone();
|
let mut orig = frame.clone();
|
||||||
blur(&orig, &mut frame);
|
|
||||||
|
|
||||||
std::mem::swap(&mut frame, &mut orig);
|
if !options.no_blur {
|
||||||
sharpen(&orig, &mut frame);
|
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
|
connection
|
||||||
.send(Command::BitmapLinearWin(
|
.send(Command::BitmapLinearWin(
|
||||||
|
|
Loading…
Reference in a new issue