fix loading of some palette and gray PNGs

also fix log
This commit is contained in:
Thomas Bernard 2019-07-02 00:09:09 +02:00
parent 1f6ceeaa3a
commit 21f815e2cd

View File

@ -6527,8 +6527,8 @@ void Load_PNG_Sub(T_IO_Context * context, FILE * file, const char * memory_buffe
switch (color_type) switch (color_type)
{ {
case PNG_COLOR_TYPE_GRAY_ALPHA: case PNG_COLOR_TYPE_GRAY_ALPHA:
//bpp = bit_depth * 2; // no more than 8bpp or else we enable true color picture loading
bpp = bit_depth; // no more than 8bpp or else we enable true color picture loading bpp = MIN(8, bit_depth * 2);
break; break;
case PNG_COLOR_TYPE_RGB: case PNG_COLOR_TYPE_RGB:
bpp = bit_depth * 3; bpp = bit_depth * 3;
@ -6539,7 +6539,8 @@ void Load_PNG_Sub(T_IO_Context * context, FILE * file, const char * memory_buffe
case PNG_COLOR_TYPE_PALETTE: case PNG_COLOR_TYPE_PALETTE:
case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_GRAY:
default: default:
bpp = bit_depth; // no more than 8bpp or else we enable true color picture loading
bpp = MIN(8, bit_depth);
} }
GFX2_Log(GFX2_DEBUG, "PNG type=%u bit_depth=%u : %ubpp\n", color_type, bit_depth, bpp); GFX2_Log(GFX2_DEBUG, "PNG type=%u bit_depth=%u : %ubpp\n", color_type, bit_depth, bpp);
@ -6577,7 +6578,7 @@ void Load_PNG_Sub(T_IO_Context * context, FILE * file, const char * memory_buffe
#endif #endif
if (length > 0 && length < COMMENT_SIZE) if (length > 0 && length < COMMENT_SIZE)
size = (int)length; size = (int)length;
GFX2_Log(GFX2_DEBUG, "PNG Text %d \"%s\" (%ul bytes): %.*s\n", GFX2_Log(GFX2_DEBUG, "PNG Text %d \"%s\" (%lu bytes): %.*s\n",
text_ptr[num_text].compression, text_ptr[num_text].key, text_ptr[num_text].compression, text_ptr[num_text].key,
(unsigned long)length, (unsigned long)length,
(int)MIN(length, 160), text_ptr[num_text].text); (int)MIN(length, 160), text_ptr[num_text].text);