Skip to content

Conversation

@halldorfannar
Copy link
Contributor

@halldorfannar halldorfannar commented Jan 21, 2026

Changes proposed in this PR

Switch from GetDIBits to CreateDIBSection for screen capture on Windows. This is more friendly in terms of how we utilize memory but did not yield performance improvements.

This PR includes a new benchmark, src/tests/bench_grab_windows.py, that was used to measure the performance before and after the changes on two different Windows machines.

My measurements shows similar performance when comparing these two approaches.

Test results on a Qualcomm arm64 + Qualcomm Adreno X1-85 GPU:

Region Original (GetDIBits) New (CreateDIBSection)
Full (2304x1536) 35.72ms (28 FPS) 34.49ms (29 FPS)
100x100 13.34ms (75 FPS) 14.67ms (68 FPS)
640x480 16.43ms (61 FPS) 14.18ms (71 FPS)

Test results on a Intel x86_64 + NVIDIA A2000 GPU:

Region Original (GetDIBits) New (CreateDIBSection)
Full (3840x2160) 81.64ms (12 FPS) 82.36ms (12 FPS)
100x100 8.33ms (120 FPS) 8.33ms (120 FPS)
640x480 8.33ms (120 FPS) 8.33ms (120 FPS)

That being said, this new approach involves less memory churn and after testing these changes against issue #268, I was unable to reproduce the issue reported there. Of course, the final verdict will be in the hands of the user who reported the original issue - but closing the issue here as fixed is the right action, so that users will be encouraged to test this on their machines.

Fixes #449, fixes #268

  • Tests added/updated
  • Documentation updated
  • Changelog entry added
  • ./check.sh passed

@halldorfannar halldorfannar changed the title Task/issue 449 create dib section Switch from GetDIBits to CreateDIBSection for screen capture on Windows Jan 21, 2026
@BoboTiG
Copy link
Owner

BoboTiG commented Jan 21, 2026

Wow, that's perfect! Thanks a lot @halldorfannar 🥂

@BoboTiG BoboTiG merged commit 616d610 into BoboTiG:main Jan 21, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate using CreateDIBSection DEBUG:root:gdi32.GetDIBits() failed. after a couple of minutes of recording

2 participants