diff --git a/Cargo.lock b/Cargo.lock index 69b3e78..ebf7f70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -348,7 +348,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -366,9 +366,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -544,18 +544,18 @@ checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -593,17 +593,17 @@ checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "windows" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets", + "windows-targets 0.52.0", ] [[package]] name = "windows-capture" -version = "1.0.28" +version = "1.0.29" dependencies = [ "image", "log", @@ -615,7 +615,7 @@ dependencies = [ [[package]] name = "windows-capture-python" -version = "1.0.28" +version = "1.0.29" dependencies = [ "log", "pyo3", @@ -626,11 +626,11 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -639,13 +639,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -654,42 +669,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "zune-inflate" version = "0.2.54" diff --git a/Cargo.toml b/Cargo.toml index f253bf2..1b49386 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture" -version = "1.0.28" +version = "1.0.29" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Rust 🔥" @@ -23,8 +23,8 @@ image = "0.24.7" log = "0.4.20" ndarray = "0.15.6" parking_lot = "0.12.1" -thiserror = "1.0.49" -windows = { version = "0.51.1", features = [ +thiserror = "1.0.50" +windows = { version = "0.52.0", features = [ "Win32_System_WinRT_Graphics_Capture", "Win32_Graphics_Direct3D11", "Win32_Foundation", diff --git a/README.md b/README.md index d743967..e5cfd61 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Add this library to your `Cargo.toml`: ```toml [dependencies] -windows-capture = "1.0.28" +windows-capture = "1.0.29" ``` or run this command diff --git a/src/capture.rs b/src/capture.rs index 429d331..798b800 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -1,5 +1,6 @@ use std::{ error::Error, + mem, os::windows::prelude::AsRawHandle, thread::{self, JoinHandle}, }; @@ -123,7 +124,7 @@ pub trait WindowsCaptureHandler: Sized { // Create A Dispatcher Queue For Current Thread trace!("Creating A Dispatcher Queue For Capture Thread"); let options = DispatcherQueueOptions { - dwSize: std::mem::size_of::() as u32, + dwSize: mem::size_of::() as u32, threadType: DQTYPE_THREAD_CURRENT, apartmentType: DQTAT_COM_NONE, }; diff --git a/src/frame.rs b/src/frame.rs index 191946e..ccdb1b0 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,9 +1,13 @@ -use std::{error::Error, path::Path}; +use std::{error::Error, path::Path, slice}; use image::{Rgba, RgbaImage}; use ndarray::{s, ArrayBase, ArrayView, Dim, OwnedRepr}; -use windows::Win32::Graphics::Direct3D11::{ - ID3D11DeviceContext, ID3D11Texture2D, D3D11_MAPPED_SUBRESOURCE, D3D11_MAP_READ, +use windows::Win32::Graphics::{ + Direct3D11::{ + ID3D11Device, ID3D11DeviceContext, ID3D11Texture2D, D3D11_BOX, D3D11_CPU_ACCESS_READ, + D3D11_MAPPED_SUBRESOURCE, D3D11_MAP_READ, D3D11_TEXTURE2D_DESC, D3D11_USAGE_STAGING, + }, + Dxgi::Common::{DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_SAMPLE_DESC}, }; use crate::settings::ColorFormat; @@ -11,13 +15,13 @@ use crate::settings::ColorFormat; /// Used To Handle Frame Errors #[derive(thiserror::Error, Eq, PartialEq, Clone, Copy, Debug)] pub enum FrameError { - #[error("Graphics Capture API Is Not Supported")] + #[error("Invalid Box Size")] InvalidSize, } /// Frame Struct Used To Get The Frame Buffer pub struct Frame<'a> { - texture: ID3D11Texture2D, + d3d_device: &'a ID3D11Device, frame_surface: ID3D11Texture2D, context: &'a ID3D11DeviceContext, width: u32, @@ -29,7 +33,7 @@ impl<'a> Frame<'a> { /// Craete A New Frame #[must_use] pub const fn new( - texture: ID3D11Texture2D, + d3d_device: &'a ID3D11Device, frame_surface: ID3D11Texture2D, context: &'a ID3D11DeviceContext, width: u32, @@ -37,7 +41,7 @@ impl<'a> Frame<'a> { color_format: ColorFormat, ) -> Self { Self { - texture, + d3d_device, frame_surface, context, width, @@ -60,34 +64,156 @@ impl<'a> Frame<'a> { /// Get The Frame Buffer pub fn buffer(&mut self) -> Result> { + // Texture Settings + let texture_desc = D3D11_TEXTURE2D_DESC { + Width: self.width, + Height: self.height, + MipLevels: 1, + ArraySize: 1, + Format: if self.color_format == ColorFormat::Rgba8 { + DXGI_FORMAT_R8G8B8A8_UNORM + } else { + DXGI_FORMAT_B8G8R8A8_UNORM + }, + SampleDesc: DXGI_SAMPLE_DESC { + Count: 1, + Quality: 0, + }, + Usage: D3D11_USAGE_STAGING, + BindFlags: 0, + CPUAccessFlags: D3D11_CPU_ACCESS_READ.0 as u32, + MiscFlags: 0, + }; + + // Create A Texture That CPU Can Read + let mut texture = None; + unsafe { + self.d3d_device + .CreateTexture2D(&texture_desc, None, Some(&mut texture))?; + }; + let texture = texture.unwrap(); + // Copy The Real Texture To Copy Texture unsafe { - self.context - .CopyResource(&self.texture, &self.frame_surface); + self.context.CopyResource(&texture, &self.frame_surface); }; // Map The Texture To Enable CPU Access let mut mapped_resource = D3D11_MAPPED_SUBRESOURCE::default(); unsafe { - self.context.Map( - &self.texture, + self.context + .Map(&texture, 0, D3D11_MAP_READ, 0, Some(&mut mapped_resource))?; + }; + + // Get The Mapped Resource Data Slice + let mapped_frame_data = unsafe { + slice::from_raw_parts( + mapped_resource.pData as *const u8, + (self.height * mapped_resource.RowPitch) as usize, + ) + }; + + // Create Frame Buffer From Slice + let frame_buffer = FrameBuffer::new( + mapped_frame_data, + self.width, + self.height, + self.color_format, + ); + + Ok(frame_buffer) + } + + /// Get A Cropped Frame Buffer + pub fn buffer_crop( + &mut self, + start_width: u32, + start_height: u32, + end_width: u32, + end_height: u32, + ) -> Result> { + if start_width >= end_width || start_height >= end_height { + return Err(Box::new(FrameError::InvalidSize)); + } + + let texture_width = end_width - start_width; + let texture_height = end_height - start_height; + + // Texture Settings + let texture_desc = D3D11_TEXTURE2D_DESC { + Width: texture_width, + Height: texture_height, + MipLevels: 1, + ArraySize: 1, + Format: if self.color_format == ColorFormat::Rgba8 { + DXGI_FORMAT_R8G8B8A8_UNORM + } else { + DXGI_FORMAT_B8G8R8A8_UNORM + }, + SampleDesc: DXGI_SAMPLE_DESC { + Count: 1, + Quality: 0, + }, + Usage: D3D11_USAGE_STAGING, + BindFlags: 0, + CPUAccessFlags: D3D11_CPU_ACCESS_READ.0 as u32, + MiscFlags: 0, + }; + + // Create A Texture That CPU Can Read + let mut texture = None; + unsafe { + self.d3d_device + .CreateTexture2D(&texture_desc, None, Some(&mut texture))?; + }; + let texture = texture.unwrap(); + + // Box Settings + let resource_box = D3D11_BOX { + left: start_width, + top: start_height, + front: 0, + right: end_width, + bottom: end_height, + back: 1, + }; + + // Copy The Real Texture To Copy Texture + unsafe { + self.context.CopySubresourceRegion( + &texture, + 0, 0, - D3D11_MAP_READ, 0, - Some(&mut mapped_resource), - )?; + 0, + &self.frame_surface, + 0, + Some(&resource_box), + ); + }; + + // Map The Texture To Enable CPU Access + let mut mapped_resource = D3D11_MAPPED_SUBRESOURCE::default(); + unsafe { + self.context + .Map(&texture, 0, D3D11_MAP_READ, 0, Some(&mut mapped_resource))?; }; // Get The Mapped Resource Data Slice let mapped_frame_data = unsafe { - std::slice::from_raw_parts( + slice::from_raw_parts( mapped_resource.pData as *const u8, - (self.height * mapped_resource.RowPitch) as usize, + (texture_height * mapped_resource.RowPitch) as usize, ) }; // Create Frame Buffer From Slice - let frame_buffer = FrameBuffer::new(mapped_frame_data, self.width, self.height); + let frame_buffer = FrameBuffer::new( + mapped_frame_data, + texture_width, + texture_height, + self.color_format, + ); Ok(frame_buffer) } @@ -139,16 +265,23 @@ pub struct FrameBuffer<'a> { raw_buffer: &'a [u8], width: u32, height: u32, + color_format: ColorFormat, } impl<'a> FrameBuffer<'a> { /// Create A New Frame Buffer #[must_use] - pub const fn new(raw_buffer: &'a [u8], width: u32, height: u32) -> Self { + pub const fn new( + raw_buffer: &'a [u8], + width: u32, + height: u32, + color_format: ColorFormat, + ) -> Self { Self { raw_buffer, width, height, + color_format, } } @@ -200,4 +333,43 @@ impl<'a> FrameBuffer<'a> { Ok(array) } } + + /// Save The Frame Buffer As An Image To The Specified Path + pub fn save_as_image>( + &self, + path: T, + ) -> Result<(), Box> { + let nopadding_buffer = self.as_raw_nopadding_buffer()?; + + let (height, width, _) = nopadding_buffer.dim(); + let mut rgba_image: RgbaImage = RgbaImage::new(width as u32, height as u32); + + if self.color_format == ColorFormat::Rgba8 { + for y in 0..height { + for x in 0..width { + let r = nopadding_buffer[(y, x, 0)]; + let g = nopadding_buffer[(y, x, 1)]; + let b = nopadding_buffer[(y, x, 2)]; + let a = nopadding_buffer[(y, x, 3)]; + + rgba_image.put_pixel(x as u32, y as u32, Rgba([r, g, b, a])); + } + } + } else { + for y in 0..height { + for x in 0..width { + let b = nopadding_buffer[(y, x, 0)]; + let g = nopadding_buffer[(y, x, 1)]; + let r = nopadding_buffer[(y, x, 2)]; + let a = nopadding_buffer[(y, x, 3)]; + + rgba_image.put_pixel(x as u32, y as u32, Rgba([r, g, b, a])); + } + } + } + + rgba_image.save(path)?; + + Ok(()) + } } diff --git a/src/graphics_capture_api.rs b/src/graphics_capture_api.rs index e35d189..7e02216 100644 --- a/src/graphics_capture_api.rs +++ b/src/graphics_capture_api.rs @@ -17,12 +17,8 @@ use windows::{ DirectX::{Direct3D11::IDirect3DDevice, DirectXPixelFormat}, }, Win32::{ - Graphics::{ - Direct3D11::{ - ID3D11Device, ID3D11DeviceContext, ID3D11Texture2D, D3D11_CPU_ACCESS_READ, - D3D11_TEXTURE2D_DESC, D3D11_USAGE_STAGING, - }, - Dxgi::Common::{DXGI_FORMAT, DXGI_SAMPLE_DESC}, + Graphics::Direct3D11::{ + ID3D11Device, ID3D11DeviceContext, ID3D11Texture2D, D3D11_TEXTURE2D_DESC, }, System::WinRT::Direct3D11::IDirect3DDxgiInterfaceAccess, UI::WindowsAndMessaging::PostQuitMessage, @@ -86,7 +82,7 @@ pub struct GraphicsCaptureApi { impl GraphicsCaptureApi { /// Create A New Graphics Capture Api Struct - pub fn new( + pub fn new( item: GraphicsCaptureItem, callback: T, capture_cursor: Option, @@ -189,107 +185,64 @@ impl GraphicsCaptureApi { let mut desc = D3D11_TEXTURE2D_DESC::default(); unsafe { frame_surface.GetDesc(&mut desc) } - // Check Frame Format - if desc.Format.0 as i32 == pixel_format.0 { - // Check If The Size Has Been Changed - if frame_content_size.Width != last_size.Width - || frame_content_size.Height != last_size.Height - { - info!( - "Size Changed From {}x{} to {}x{} -> Recreating Device", - last_size.Width, - last_size.Height, - frame_content_size.Width, - frame_content_size.Height, - ); - let direct3d_device_recreate = &direct3d_device_recreate; - frame_pool_recreate - .Recreate( - &direct3d_device_recreate.0, - pixel_format, - 2, - frame_content_size, - ) - .unwrap(); - - last_size = frame_content_size; - - return Ok(()); - } - - // Set Width & Height - let texture_width = desc.Width; - let texture_height = desc.Height; - - // Texture Settings - let texture_desc = D3D11_TEXTURE2D_DESC { - Width: texture_width, - Height: texture_height, - MipLevels: 1, - ArraySize: 1, - Format: DXGI_FORMAT(pixel_format.0 as u32), - SampleDesc: DXGI_SAMPLE_DESC { - Count: 1, - Quality: 0, - }, - Usage: D3D11_USAGE_STAGING, - BindFlags: 0, - CPUAccessFlags: D3D11_CPU_ACCESS_READ.0 as u32, - MiscFlags: 0, - }; - - // Create A Texture That CPU Can Read - let mut texture = None; - unsafe { - d3d_device_frame_pool.CreateTexture2D( - &texture_desc, - None, - Some(&mut texture), - )?; - }; - let texture = texture.unwrap(); - - // Create A Frame - let frame = Frame::new( - texture, - frame_surface, - &context, - texture_width, - texture_height, - color_format, + // Check If The Size Has Been Changed + if frame_content_size.Width != last_size.Width + || frame_content_size.Height != last_size.Height + { + info!( + "Size Changed From {}x{} to {}x{} -> Recreating Device", + last_size.Width, + last_size.Height, + frame_content_size.Width, + frame_content_size.Height, ); + let direct3d_device_recreate = &direct3d_device_recreate; + frame_pool_recreate + .Recreate( + &direct3d_device_recreate.0, + pixel_format, + 2, + frame_content_size, + ) + .unwrap(); + + last_size = frame_content_size; - // Init Internal Capture Control - let stop = Arc::new(AtomicBool::new(false)); - let internal_capture_control = InternalCaptureControl::new(stop.clone()); - - // Send The Frame To Trigger Struct - let result = callback_frame_pool - .lock() - .on_frame_arrived(frame, internal_capture_control); - - if stop.load(atomic::Ordering::Relaxed) || result.is_err() { - let _ = RESULT - .replace(Some(result)) - .expect("Failed To Replace RESULT"); + return Ok(()); + } - closed_frame_pool.store(true, atomic::Ordering::Relaxed); + // Set Width & Height + let texture_width = desc.Width; + let texture_height = desc.Height; + + // Create A Frame + let frame = Frame::new( + &d3d_device_frame_pool, + frame_surface, + &context, + texture_width, + texture_height, + color_format, + ); + + // Init Internal Capture Control + let stop = Arc::new(AtomicBool::new(false)); + let internal_capture_control = InternalCaptureControl::new(stop.clone()); + + // Send The Frame To Trigger Struct + let result = callback_frame_pool + .lock() + .on_frame_arrived(frame, internal_capture_control); + + if stop.load(atomic::Ordering::Relaxed) || result.is_err() { + let _ = RESULT + .replace(Some(result)) + .expect("Failed To Replace RESULT"); - // To Stop Messge Loop - unsafe { PostQuitMessage(0) }; - } - } else { closed_frame_pool.store(true, atomic::Ordering::Relaxed); // To Stop Messge Loop unsafe { PostQuitMessage(0) }; - - // Notify The Struct That The Capture Session Is Closed - let result = callback_frame_pool.lock().on_closed(); - - let _ = RESULT - .replace(Some(result)) - .expect("Failed To Replace RESULT"); } Result::Ok(()) @@ -390,7 +343,7 @@ impl GraphicsCaptureApi { } } -// Close Screen Capture And Deallocate Memory +// Close Capture Session impl Drop for GraphicsCaptureApi { fn drop(&mut self) { if let Some(frame_pool) = self.frame_pool.take() { diff --git a/src/lib.rs b/src/lib.rs index 1fbcdc0..56d1ec6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! //! ```toml //! [dependencies] -//! windows-capture = "1.0.28" +//! windows-capture = "1.0.29" //! ``` //! or run this command //! diff --git a/src/monitor.rs b/src/monitor.rs index 092574a..d4f9b1b 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -1,4 +1,4 @@ -use std::error::Error; +use std::{error::Error, ptr}; use windows::{ Graphics::Capture::GraphicsCaptureItem, @@ -57,7 +57,7 @@ impl Monitor { None, None, Some(Self::enum_monitors_callback), - LPARAM(std::ptr::addr_of_mut!(monitors) as isize), + LPARAM(ptr::addr_of_mut!(monitors) as isize), ) .ok()?; }; diff --git a/src/window.rs b/src/window.rs index cbe62f7..d590780 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,4 +1,4 @@ -use std::error::Error; +use std::{error::Error, ptr}; use log::warn; use windows::{ @@ -127,7 +127,7 @@ impl Window { EnumChildWindows( GetDesktopWindow(), Some(Self::enum_windows_callback), - LPARAM(std::ptr::addr_of_mut!(windows) as isize), + LPARAM(ptr::addr_of_mut!(windows) as isize), ) .ok()?; }; diff --git a/windows-capture-python/Cargo.lock b/windows-capture-python/Cargo.lock index 61b41f0..dd7b9a5 100644 --- a/windows-capture-python/Cargo.lock +++ b/windows-capture-python/Cargo.lock @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ diff --git a/windows-capture-python/Cargo.toml b/windows-capture-python/Cargo.toml index 6961e9b..5d449f6 100644 --- a/windows-capture-python/Cargo.toml +++ b/windows-capture-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture-python" -version = "1.0.28" +version = "1.0.29" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Python 🔥" @@ -25,7 +25,7 @@ crate-type = ["cdylib"] log = "0.4.20" pyo3 = { version = "0.20.0", features = ["extension-module"] } pyo3-log = "0.9.0" -windows = { version = "0.51.1", features = [ +windows = { version = "0.52.0", features = [ "Win32_UI_WindowsAndMessaging", "Win32_Foundation", ] } diff --git a/windows-capture-python/pyproject.toml b/windows-capture-python/pyproject.toml index bbc3832..8c6d56e 100644 --- a/windows-capture-python/pyproject.toml +++ b/windows-capture-python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "windows-capture" -version = "1.0.28" +version = "1.0.29" description = "Fastest Windows Screen Capture Library For Python 🔥" readme = "README.md" requires-python = ">=3.9"