From 9a0fbebac30d279da6de44a2181f9d43803b8e61 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sat, 31 Aug 2013 16:04:58 -0400 Subject: [PATCH] Fix bug when going from smaller to higher bit depth --- PVRTCEncoder/src/Pixel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PVRTCEncoder/src/Pixel.cpp b/PVRTCEncoder/src/Pixel.cpp index 2b01800..74f03e5 100644 --- a/PVRTCEncoder/src/Pixel.cpp +++ b/PVRTCEncoder/src/Pixel.cpp @@ -54,6 +54,7 @@ #include #include +#include namespace PVRTCC { @@ -119,8 +120,8 @@ namespace PVRTCC { uint8 ret = 0; while(bitsLeft > oldDepth) { ret |= val; - ret <<= oldDepth; bitsLeft -= oldDepth; + ret <<= std::min(bitsLeft, oldDepth); } return ret | (val >> (oldDepth - bitsLeft));