From 8c2127c08a2ef58b2bbc4abe55be08e2a4c63edf Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sat, 31 Aug 2013 16:05:50 -0400 Subject: [PATCH] When packing ARGB pixels make sure to convert them to 8-bit depth first --- PVRTCEncoder/src/Pixel.cpp | 17 +++++++++++++++++ PVRTCEncoder/src/Pixel.h | 12 +----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/PVRTCEncoder/src/Pixel.cpp b/PVRTCEncoder/src/Pixel.cpp index 0ec918d..8db81f6 100644 --- a/PVRTCEncoder/src/Pixel.cpp +++ b/PVRTCEncoder/src/Pixel.cpp @@ -147,4 +147,21 @@ namespace PVRTCC { } } + uint32 Pixel::PackRGBA() const { + Pixel eightBit(*this); + const uint8 eightBitDepth[4] = { 8, 8, 8, 8 }; + eightBit.ChangeBitDepth(eightBitDepth); + + uint32 r = 0; + r |= eightBit.A(); + r <<= 8; + r |= eightBit.B(); + r <<= 8; + r |= eightBit.G(); + r <<= 8; + r |= eightBit.R(); + return r; + } + + } // namespace PVRTCC diff --git a/PVRTCEncoder/src/Pixel.h b/PVRTCEncoder/src/Pixel.h index 2af0797..7598dd6 100644 --- a/PVRTCEncoder/src/Pixel.h +++ b/PVRTCEncoder/src/Pixel.h @@ -105,17 +105,7 @@ class Pixel { } } - uint32 PackRGBA() const { - uint32 r = 0; - r |= m_A; - r <<= 8; - r |= m_B; - r <<= 8; - r |= m_G; - r <<= 8; - r |= m_R; - return r; - } + uint32 PackRGBA() const; private: union {