embedded-graphics: Images don't work correctly between color formats?
- Version of embedded-graphics in use (if applicable): 0.6.2
- Target: QEMU 5.0.0
- If using real hardware: Custom
Description of the problem/feature request/other
Okay, so first some background:
I’m using this crate for graphics in QEMU OVMF UEFI, which only knows the pixel format at runtime,
so I’ve implemented DrawTarget generically over Into<Bgr888> and just use Rgb888::from if need be.(blt and pixel bitmask currently unsupported). So far so good, the circle and some text example colors are correct, despite the code using Rgb565.
And onto the issue:
Then I wanted to display images, and found that Image<Tga, Rgb888> results in the colors being wrong. It compiles, it should be converting through Into<Bgr888>, yet the colors are wrong?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (13 by maintainers)
Rgb888::new(0x11, 0x22, 0x33).into_storage()results in anu32with a value of0x00112233. When you convert that value into an array by usingto_ne_byteson anx86_64machine you will get:[0x33, 0x22, 0x11, 0x00].The resulting array in this case would be
[0x00, 0x11, 0x22, 0x33], so you will need to remove the first element and not the last element of the array when copying it to the framebuffer.That’s a good idea. I’ve implemented this in PR #429.
That depends on the endianness of the machine and I agree that it can get weird.
I’m glad that it works now and if you don’t have any additional questions feel free to close the issue.