diff --git a/tools/gbagfx/convert_png.c b/tools/gbagfx/convert_png.c index c9c240efbba0..58371229c06d 100644 --- a/tools/gbagfx/convert_png.c +++ b/tools/gbagfx/convert_png.c @@ -62,7 +62,7 @@ static unsigned char *ConvertBitDepth(unsigned char *src, int srcBitDepth, int d for (j = 8 - srcBitDepth; j >= 0; j -= srcBitDepth) { - unsigned char pixel = (srcByte >> j) % (1 << destBitDepth); + unsigned char pixel = ((srcByte >> j) % (1 << srcBitDepth)) % (1 << destBitDepth); *dest |= pixel << destBit; destBit -= destBitDepth; if (destBit < 0)