From fe9bb94d6caecae0fdb0b2802b8f26b084224ee0 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Thu, 21 Jun 2012 18:24:33 -0700 Subject: [PATCH] DirectXTex: fixed color order for 24bpp legacy DDS file expansions --- DirectXTex/DirectXTexDDS.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index 1c7f266..0146640 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -689,9 +689,10 @@ static bool _LegacyExpandScanline( _Out_bytecap_(outSize) LPVOID pDestination, s for( size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < outSize)); icount += 3, ocount += 4 ) { - uint32_t t1 = *sPtr; + // 24bpp Direct3D 9 files are actually BGR, so need to swizzle as well + uint32_t t1 = ( *(sPtr) << 16 ); uint32_t t2 = ( *(sPtr+1) << 8 ); - uint32_t t3 = ( *(sPtr+2) << 16 ); + uint32_t t3 = *(sPtr+2); *(dPtr++) = t1 | t2 | t3 | 0xff000000; sPtr += 3;