mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix rendering regression with TGA type 1 files with BGRA8 color (#15402)
TGA uses BGR(A)8, stored in memory in that order. Irrlicht typically expects 0xAARRGGBB, which depends on endianness. (This means that on little endian, no [B][G][R][A] -> 0xAARRGGBB conversion needs to be done, but Irrlicht was swapping the bytes.) This makes both conversion functions consistently convert from [B][G][R]([A]) to 0xAARRGGBB (SColor), documents them properly and moves them to CImageLoaderTGA.cpp so no poor soul shall be fooled by them in the near future. --------- Co-authored-by: Ælla Chiana Moskopp <erle@dieweltistgarnichtso.net>
This commit is contained in:
parent
138052adfc
commit
15e8f9e6a0
4 changed files with 32 additions and 33 deletions
|
@ -95,6 +95,8 @@ SColor CImage::getPixel(u32 x, u32 y) const
|
|||
case ECF_A8R8G8B8:
|
||||
return ((u32 *)Data)[y * Size.Width + x];
|
||||
case ECF_R8G8B8: {
|
||||
// FIXME this interprets the memory as [R][G][B], whereas SColor is stored as
|
||||
// 0xAARRGGBB, meaning it is lies in memory as [B][G][R][A] on a little endian machine.
|
||||
u8 *p = Data + (y * 3) * Size.Width + (x * 3);
|
||||
return SColor(255, p[0], p[1], p[2]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue