Skip to content

Commit

Permalink
Bug Fix 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
NiiightmareXD committed Jan 14, 2024
1 parent 692f63b commit 98f34e9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "windows-capture"
version = "1.0.59"
version = "1.0.60"
authors = ["NiiightmareXD"]
edition = "2021"
description = "Fastest Windows Screen Capture Library For Rust 🔥"
Expand Down Expand Up @@ -41,6 +41,9 @@ windows = { version = "0.52.0", features = [
"Graphics_Imaging",
"Storage_Streams",
"Foundation",
"Media_MediaProperties",
"Media_Core",
"Media_Transcoding",
] }

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add this library to your `Cargo.toml`:

```toml
[dependencies]
windows-capture = "1.0.59"
windows-capture = "1.0.60"
```
or run this command

Expand Down
8 changes: 6 additions & 2 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub enum CaptureControlError<E> {
#[error("Failed To Post Thread Message")]
FailedToPostThreadMessage,
#[error(transparent)]
StoppedHandlerError(E),
#[error(transparent)]
WindowsCaptureError(#[from] WindowsCaptureError<E>),
}

Expand Down Expand Up @@ -409,7 +411,9 @@ pub trait WindowsCaptureHandler: Sized {
capture_control: InternalCaptureControl,
) -> Result<(), Self::Error>;

/// Called When The Capture Item Closes Usually When The Window Closes,
/// Optional Handler Called When The Capture Item Closes Usually When The Window Closes,
/// Capture Session Will End After This Function Ends
fn on_closed(&mut self) -> Result<(), Self::Error>;
fn on_closed(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
10 changes: 7 additions & 3 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<'a> Frame<'a> {
path: T,
format: ImageFormat,
) -> Result<(), Error> {
let frame_buffer = self.buffer()?;
let mut frame_buffer = self.buffer()?;

frame_buffer.save_as_image(path, format)?;

Expand Down Expand Up @@ -372,7 +372,11 @@ impl<'a> FrameBuffer<'a> {
}

/// Save The Frame Buffer As An Image To The Specified Path (Only `ColorFormat::Rgba8` And `ColorFormat::Bgra8`)
pub fn save_as_image<T: AsRef<Path>>(&self, path: T, format: ImageFormat) -> Result<(), Error> {
pub fn save_as_image<T: AsRef<Path>>(
&'a mut self,
path: T,
format: ImageFormat,
) -> Result<(), Error> {
let encoder = match format {
ImageFormat::Jpeg => BitmapEncoder::JpegEncoderId()?,
ImageFormat::Png => BitmapEncoder::PngEncoderId()?,
Expand All @@ -398,7 +402,7 @@ impl<'a> FrameBuffer<'a> {
self.height,
1.0,
1.0,
self.raw_buffer,
self.as_raw_nopadding_buffer()?,
)?;

encoder.FlushAsync()?.get()?;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//!
//! ```toml
//! [dependencies]
//! windows-capture = "1.0.59"
//! windows-capture = "1.0.60"
//! ```
//! or run this command
//!
Expand Down
2 changes: 1 addition & 1 deletion windows-capture-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "windows-capture-python"
version = "1.0.59"
version = "1.0.60"
authors = ["NiiightmareXD"]
edition = "2021"
description = "Fastest Windows Screen Capture Library For Python 🔥"
Expand Down
2 changes: 1 addition & 1 deletion windows-capture-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "windows-capture"
version = "1.0.59"
version = "1.0.60"
description = "Fastest Windows Screen Capture Library For Python 🔥"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
Binary file not shown.

0 comments on commit 98f34e9

Please sign in to comment.