-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Always return little-endian packed value in Rgba8::to_u32 #100
Conversation
If the intention is for the bytes of r, g, b and a to always be in the same memory order, I believe this patch is required. In the order of memory of `to_u8_array`, the red channel is at the lowest memory address and therefore (in little endian) the least significant byte. On a big endian system, using `from_le_bytes` would move the red byte to the highest memory addres.
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.
This function has gone through all three of these functions in the last couple of weeks.
We really need some miri testing for a big-endian system...
I think... that I agree that this is right.
The invocation $ cargo miri test --target s390x-unknown-linux-gnu --features bytemuck -- rgba8:: fails on main:
It passes with this patch. |
I've done a PR with Miri in CI in #101 ... |
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.
Okay ... and we'll use Miri in CI to keep things right going forward!
Going to merge this now so that I can perhaps do the release now. (Breaking the usual policy...) |
(And PremulRgba8.)
If the intention is for the bytes of R, G, B and A to always be in the same memory order, I believe this patch is required. The docstring on the method suggests that's the intention.
In the order of memory of
Rgba8::to_u8_array
, the red channel is at the lowest memory address and therefore (in little endian) the least significant byte. On a big endian system, usingfrom_le_bytes
would move the red byte to the highest memory address.