Repository navigation
Fix broken screenshots on copy by forcing opaque alpha (#5) - #15
Open
CodyKoInABox wants to merge 3 commits into
Open
CodyKoInABox wants to merge 3 commits into
CodyKoInABox wants to merge 3 commits into
Conversation
Single-monitor captures (region and cursor-monitor fullscreen) passed the capture backend's alpha byte through unchanged. Only cursor compositing normalized it, so with include_cursor disabled the frame could carry zero alpha. The clipboard DIB and PNG encoder both store that alpha verbatim, so pasted and saved screenshots rendered as transparent or broken. - Normalize alpha at the capture boundary for single-monitor captures. - Normalize alpha after virtual-desktop compositing instead of before it, since compositing overwrote the pre-filled values. - Write opaque alpha into the CF_DIBV5 payload. Fixes #5 Co-authored-by: codykoinabox <codykoinabox@gmail.com>
Current stable clippy flags chunks_exact with a constant chunk size (chunks_exact_to_as_chunks), and CI runs clippy with -D warnings. Switch the affected pixel loops to slice::as_chunks, which is stable since Rust 1.88, the crate's MSRV. Behavior is unchanged: both forms drop the same partial tail, which is always empty for valid RGBA buffers. Co-authored-by: codykoinabox <codykoinabox@gmail.com>
The bin target hits the same chunks_exact_to_as_chunks lint that the library targets already hit, so CI's clippy -D warnings still fails without it. Co-authored-by: codykoinabox <codykoinabox@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
Region captures and cursor-monitor fullscreen captures went through
capture_monitor, which passed the capture backend's RGBA buffer through unchanged. The alpha byte was only normalized as a side effect of native cursor compositing (composite_cursorwritesu8::MAX). Withinclude_cursordisabled, or when the cursor is not showing, frames kept whatever alpha the backend returned.Both export paths store that alpha verbatim:
CF_DIBV5payload uses an alpha mask, so apps that honor it paste the screenshot as transparent or broken.The virtual-desktop path had a pre-fill loop for opaque alpha, but
composite_monitoroverwrote it with each monitor's alpha, so it did not protect monitor pixels either.Changes
capture_monitorforces alpha to opaque before building theFrame.rgba_to_bgra(clipboard) always writes opaque alpha, so the copied DIB is opaque regardless of the source frame.Tests
forced_alpha_makes_every_capture_pixel_opaquecomposited_zero_alpha_monitor_pixels_become_opaqueconverts_rgba_to_opaque_bgra(replaces the previous passthrough assertion)Tests are Windows-only and run in the Windows CI job. Not run locally (Linux host cannot build the
windowstarget deps), and not verified on a real desktop.Fixes #5