From fa88d9733800600350963850509dbe6a1b7208f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86lla=20Chiana=20Moskopp?= Date: Fri, 8 Nov 2024 22:12:12 +0100 Subject: [PATCH] Fix regressions in rendering TGA type 1 files with color format B8G8R8A8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CColorConverter::convert_B8G8R8A8toA8R8G8B8() is only used when handling TGA type 1 files, i.e. those that contain a colormap. At some point, the way colors are converted got broken (at least on x86 and x86_64), so the textures loaded from the files had their color channels switched around. This patch replaces the non-working code with a lightly modified version of CColorConverter::convert_B8G8R8toA8R8G8B8() – which worked just fine. --- irr/src/CColorConverter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/irr/src/CColorConverter.cpp b/irr/src/CColorConverter.cpp index 96b22c544..204bf9ae3 100644 --- a/irr/src/CColorConverter.cpp +++ b/irr/src/CColorConverter.cpp @@ -518,16 +518,13 @@ void CColorConverter::convert_A8R8G8B8toA8B8G8R8(const void *sP, s32 sN, void *d void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void *sP, s32 sN, void *dP) { u8 *sB = (u8 *)sP; - u8 *dB = (u8 *)dP; + u32 *dB = (u32 *)dP; for (s32 x = 0; x < sN; ++x) { - dB[0] = sB[3]; - dB[1] = sB[2]; - dB[2] = sB[1]; - dB[3] = sB[0]; + *dB = (sB[3] << 24) | (sB[2] << 16) | (sB[1] << 8) | sB[0]; sB += 4; - dB += 4; + ++dB; } } -- 2.30.2