Skip to content

Commit

Permalink
Further Optimizations 🔥
Browse files Browse the repository at this point in the history
	new file:   .github/workflows/python.yml
	modified:   Cargo.lock
	modified:   Cargo.toml
	new file:   Python/WindowsCapture/main.py
	new file:   Python/windows-capture-native/.gitignore
	new file:   Python/windows-capture-native/Cargo.lock
	new file:   Python/windows-capture-native/Cargo.toml
	new file:   Python/windows-capture-native/LICENCE
	new file:   Python/windows-capture-native/pyproject.toml
	new file:   Python/windows-capture-native/src/lib.rs
	modified:   README.md
	new file:   examples/basic.rs
	modified:   src/buffer.rs
	modified:   src/capture.rs
	modified:   src/frame.rs
	modified:   src/graphics_capture_api.rs
	modified:   src/lib.rs
  • Loading branch information
NiiightmareXD committed Nov 2, 2023
1 parent d34fc44 commit 3bd2ced
Show file tree
Hide file tree
Showing 17 changed files with 1,116 additions and 113 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Python

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build -p windows-capture-native --verbose
- name: Run tests
run: cargo test -p windows-capture-native --verbose
99 changes: 99 additions & 0 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "windows-capture"
version = "1.0.22"
authors = ["NiiightmareXD"]
edition = "2021"
description = "Simple Windows Screen Capture Library For Rust And Python 🔥"
description = "Fastest Windows Screen Capture Library For Rust 🔥"
documentation = "https://docs.rs/windows-capture"
readme = "README.md"
repository = "https://github.com/NiiightmareXD/windows-capture"
Expand All @@ -16,6 +16,7 @@ categories = [
"gui",
"multimedia",
]
resolver = "2"

[dependencies]
image = "0.24.7"
Expand All @@ -38,4 +39,8 @@ windows = { version = "0.51.1", features = [
"Graphics_DirectX_Direct3D11",
"Foundation_Metadata",
"Win32_UI_HiDpi",
"Win32_System_Com",
] }

[workspace]
members = ["Python/windows-capture-native"]
55 changes: 55 additions & 0 deletions Python/WindowsCapture/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Python Version Is NOT Complete Yet


from windows_capture_native import NativeWindowsCapture


class Capture:
def __init__(self, capture_cursor: bool = True, draw_border: bool = False):
self.frame_handler = None
self.closed_handler = None
self.capture = NativeWindowsCapture(
False, False, self.on_frame_arrived, self.on_closed
)
self.capture_cursor = capture_cursor
self.draw_border = draw_border

def start(self):
self.capture.start()

def on_frame_arrived(self, frame):
if self.frame_handler:
self.frame_handler(frame)
else:
raise Exception("on_frame_arrived Event Handler Is Not Set")

def on_closed(self):
if self.closed_handler:
self.closed_handler()
else:
raise Exception("on_closed Event Handler Is Not Set")

def event(self, handler):
if handler.__name__ == "on_frame_arrived":
self.frame_handler = handler
elif handler.__name__ == "on_closed":
self.closed_handler = handler
else:
raise Exception("Invalid Event Handler Use on_frame_arrived Or on_closed")
return handler


capture = Capture(False, False)


@capture.event
def on_frame_arrived(frame):
print("on_frame_arrived")


@capture.event
def on_closed():
print("on_closed")


capture.start()
1 change: 1 addition & 0 deletions Python/windows-capture-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading

0 comments on commit 3bd2ced

Please sign in to comment.