Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform gamma correction in screenshot.rs #96

Merged
merged 5 commits into from Feb 8, 2022
Merged

Perform gamma correction in screenshot.rs #96

merged 5 commits into from Feb 8, 2022

Conversation

LoganDark
Copy link
Contributor

Right now, screenshot.rs takes the raw rgb values and pipes them into a PNG image.

This is not sufficient; viewers generally assume that pixel data in PNGs is sRGB (unless otherwise specified, which screenshot.rs does not). So map it from linear RGB to sRGB. This results in graphics looking much smoother on computer monitors.

@LoganDark
Copy link
Contributor Author

Non-gamma-corrected (current behavior, left) and gamma-corrected (PR behavor, right) screenshots, side by side:

Full size (if you have a 1x screen):

The one on the right looks closer to how the reMarkable physically displays the framebuffer. It's just that the PNG image had to be prepared (gamma correction) to properly look that way in an image viewer, which generally expects sRGB from PNG images. And notice how the outlines around the buttons look a lot more consistent on the gamma-corrected screenshot.

@LoganDark
Copy link
Contributor Author

Not sure how you'll feel about the last commit but I thought it'd be worth pushing so you can try it out. I'll probably need to revert it before this is merged :P

@LoganDark
Copy link
Contributor Author

It might be worth incorporating a couple LUTs like that one into libremarkable itself to provide convenience functions like, for example, to_srgb, or from_srgb.

examples/screenshot.rs Outdated Show resolved Hide resolved
@LoganDark
Copy link
Contributor Author

Embedded LUT:

real    0m0.560s
user    0m0.506s
sys     0m0.050s

rgb565 crate:

real    0m0.578s
user    0m0.556s
sys     0m0.021s

Not sure where the mismatch is, but it's close enough. Still faster than the original (0.679s)!

@LoganDark
Copy link
Contributor Author

Is this good to merge? Anything more I need to address?

Copy link
Collaborator

@LinusCDE LinusCDE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it out and it works fine!

I should also consider adding this to #94 then.

@LinusCDE LinusCDE merged commit 641b250 into canselcik:master Feb 8, 2022
@LoganDark LoganDark deleted the screenshot-gamma branch February 8, 2022 22:53
LinusCDE added a commit to LinusCDE/libremarkable that referenced this pull request Feb 8, 2022
LinusCDE added a commit to LinusCDE/libremarkable that referenced this pull request Dec 4, 2023
fenollp pushed a commit that referenced this pull request Dec 5, 2023
* Support multiple formats and default to png

* Replace BufWriter with Cursor

There is no point in BufWriter here, as it operates on memory and not files.

* Show encoding speed in console

* Add html page to select format by default

* Rename some variables to be more explicit

* Include gamma correction added to screenshot in #96
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.

None yet

3 participants