From 1ffbdea2b888bd62150cbd0115f86762b560664c Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Sat, 31 Aug 2013 16:05:28 -0400 Subject: [PATCH] Make sure to handle 0 bit depth a bit more gracefully --- PVRTCEncoder/src/Pixel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PVRTCEncoder/src/Pixel.cpp b/PVRTCEncoder/src/Pixel.cpp index 74f03e5..0ec918d 100644 --- a/PVRTCEncoder/src/Pixel.cpp +++ b/PVRTCEncoder/src/Pixel.cpp @@ -112,7 +112,7 @@ namespace PVRTCC { assert(newDepth <= 8); assert(oldDepth <= 8); - if(oldDepth == newDepth) { + if(oldDepth == newDepth || oldDepth == 0) { // Do nothing return val; } else if(newDepth > oldDepth) { @@ -128,8 +128,12 @@ namespace PVRTCC { } else { // oldDepth > newDepth - uint8 bitsWasted = oldDepth - newDepth; - return val >> bitsWasted; + if(newDepth == 0) { + return 0xFF; + } else { + uint8 bitsWasted = oldDepth - newDepth; + return val >> bitsWasted; + } } assert(!"We shouldn't get here.");