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
Make rgb565 conversion algorithms a bit better #95
Conversation
This actually fixes a bug in In any case everything works now and everything interacts perfectly with the simulator I've set up...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid improvement, and thanks for the tests!
Haven't heard of any issues building on desktop before... which dep failed to build / any idea why?
I had issues building evdev and epoll since I was cross-compiling for Windows (WSL 1 - I don't like VMs - no graphics support). #92 adds the ability to exclude those from the build. Although it looks like nobody's wanted to touch it for a while - now that I depend on it, I need it merged at some point but I fear that it's too big/complicated of a change now. I've been testing this by merging it into #92 on my local checkout and then running There's also the visual test of running my app on #92 with and without this PR. Without, color blending is totally scuffed, but with, it works fine. It's literally a case where |
Make sense - thanks! |
I added tests for the specific colors, and I'm 100% sure that red/green were swapped. I'm also 100% sure that the endianness is CORRECT this time - both in terms of the byte order of the u16 and the order of the components in that u16. Test passes. Phew........ |
You should probably squash all these commits when you merge. |
This comment has been minimized.
This comment has been minimized.
Just for the record the endianness is now correct and proven to work correctly on-device. Since the encoding and decoding algorithms match, I was able to run to prove beyond a shadow of a doubt that YES, we understand the rgb565_le format correctly. ( For those following along at home, xochitl only writes color information to the framebuffer if screenshare is turned on. |
@bkirwi Next time maybe select the "Squash and merge" option? |
The old algorithm has some unpleasant tinting. Native components
[0xFF, 0xFF]
don't result in rgb components[0xFF, 0xFF, 0xFF]
but rather[0xF8, 0xFC, 0xF8]
. This affects screenshots for example.Obviously some fudging is needed in order to come up with the "extra resolution" in rgb8 to make the mins and maxes match up. Roundtripping from 565 -> 888 -> 565 is still a thing. And now it's a part of the test suite, which verifies that every rgb565 value can be roundtripped to rgb8 and back. And that rgb565 -> rgb8 conversions behave properly.
The new conversion routines still only use integer arithmetic. I haven't benchmarked them but they should actually be slightly faster than the old routines.
Note that I tested these on my desktop machine which required #92 in order to get libremarkable to build. Just a preview of how useful that can be.