Merge pull request #1842 from GriffinRichards/gbagfx-pals
Automatically constrain png pixels to bit depth
Before Width: | Height: | Size: 488 B After Width: | Height: | Size: 432 B |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 432 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 391 B |
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 377 B |
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 387 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 403 B |
@ -62,10 +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 << srcBitDepth);
|
||||
|
||||
if (pixel >= (1 << destBitDepth))
|
||||
FATAL_ERROR("Image exceeds the maximum color value for a %ibpp image.\n", destBitDepth);
|
||||
unsigned char pixel = (srcByte >> j) % (1 << destBitDepth);
|
||||
*dest |= pixel << destBit;
|
||||
destBit -= destBitDepth;
|
||||
if (destBit < 0)
|
||||
|