11#[ cfg( target_os = "macos" ) ]
2- use std:: { os:: macos:: raw} ;
2+ use std:: os:: macos:: raw;
33
4- use image:: { Rgb , RgbImage , ImageBuffer , RgbaImage , buffer:: ConvertBuffer , imageops:: resize, imageops:: FilterType :: Triangle } ;
4+ use image:: {
5+ buffer:: ConvertBuffer , imageops:: resize, imageops:: FilterType :: Triangle , ImageBuffer , Rgb ,
6+ RgbImage , RgbaImage ,
7+ } ;
58
69use crate :: common:: color:: Color ;
710use crate :: common:: PixelRect ;
@@ -23,21 +26,24 @@ pub fn capture_absolute(
2326 . capture_area ( * left, * top, * width as u32 , * height as u32 )
2427 . expect ( "capture failed" ) ;
2528 let mut rgb_img = png_decode ( png_img) . unwrap ( ) ;
26- if rgb_img. width ( ) as i32 > * width && rgb_img. height ( ) as i32 > * height {
29+ if rgb_img. width ( ) as i32 > * width && rgb_img. height ( ) as i32 > * height {
2730 rgb_img = resize ( & rgb_img, ( * width) as u32 , ( * height) as u32 , Triangle ) ;
2831 }
2932 Ok ( rgb_img)
3033}
3134
32- fn png_decode ( png_img : screenshots:: Image ) -> Result < RgbImage , String > {
35+ fn png_decode ( png_img : screenshots:: Image ) -> Result < RgbImage , String > {
3336 let png_decoder = Decoder :: new ( png_img. buffer ( ) . as_slice ( ) ) ;
3437 let mut png_reader = png_decoder. read_info ( ) . unwrap ( ) ;
3538
3639 let mut png_data_buf = vec ! [ 0 ; png_reader. output_buffer_size( ) ] ;
3740
3841 let info = png_reader. next_frame ( & mut png_data_buf) . unwrap ( ) ;
39-
40- assert ! ( info. color_type == png:: ColorType :: Rgba , "Not rgba format image" ) ;
42+
43+ assert ! (
44+ info. color_type == png:: ColorType :: Rgba ,
45+ "Not rgba format image"
46+ ) ;
4147
4248 let mut buffer = png_data_buf[ ..info. buffer_size ( ) ] . to_vec ( ) ;
4349
@@ -63,7 +69,7 @@ pub fn capture_absolute_image(
6369
6470 let mut buffer = png_decode ( image) . unwrap ( ) ;
6571
66- if buffer. width ( ) as i32 > * width && buffer. height ( ) as i32 > * height {
72+ if buffer. width ( ) as i32 > * width && buffer. height ( ) as i32 > * height {
6773 buffer = resize ( & buffer, ( * width) as u32 , ( * height) as u32 , Triangle ) ;
6874 }
6975 Ok ( buffer)
0 commit comments