Use stb_image_write to save PNG screenshots#289
Closed
oznogon wants to merge 2 commits into
Closed
Conversation
Add the stb_image_write header-only library to write a screenshot to a PNG file on a background thread. Add Window::saveScreenshotToFile(w,h) function and screenshot_key keybinding. This allows for a few advantages over OS screenshot capabilities: - Works when rendering via KMSDRM - No OS chrome, drop shadows, etc. in screenshots; this saves only what's in the framebuffer - Should work per-window, but no multi-monitor setup to test behavior on If the additional vendored lib is undesirable, this could be implemented without stb_image_write to save uncompressed TGA or BMP screenshots, but the sizes of them would be dramatically larger (about 9MB on a display of 2.7k pixels vs. ~700-900kb PNG).
Owner
|
I'm wondering if I'm fine with this or rather have it as part of the Image class as in SP2: https://github.com/daid/SeriousProton2/blob/master/src/graphics/image.cpp#L132 |
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.
Add the stb_image_write header-only library to write a screenshot to a PNG file on a background thread. Add
Window::saveScreenshotToFile(w,h)function andscreenshot_keykeybinding.This allows for a few advantages over OS screenshot capabilities:
If the additional vendored lib is undesirable, this could be implemented without stb_image_write to save uncompressed TGA or BMP screenshots, but the sizes of them would be dramatically larger (about 9MB on a display of 2.7k pixels vs. ~700-900kb PNG).
stb_image_write is monkey patched to avoid CI failing on
-Wextrawarnings from nothings/stb#1099.nothings comment from 2021 on issue 1099:
Upstream PR nothings/stb#1311 (2022, still open) implements this change.