better dithering, keep aspect ratio, send image #2
					 2 changed files with 36 additions and 8 deletions
				
			
		
							
								
								
									
										16
									
								
								src/cli.rs
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/cli.rs
									
										
									
									
									
								
							|  | @ -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, | ||||
| } | ||||
|  |  | |||
|  | @ -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( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue