From 1a56e9c9268976936eeab9fe97eb664b847e444c Mon Sep 17 00:00:00 2001 From: glennrp Date: Wed, 25 Apr 2012 17:06:57 +0000 Subject: [PATCH] Display PNG colortype as a string in debugging log --- coders/png.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/coders/png.c b/coders/png.c index 541beaaf4..da666610c 100644 --- a/coders/png.c +++ b/coders/png.c @@ -1052,6 +1052,33 @@ LosslessReduceDepthOK(Image *image,ExceptionInfo *exception) } #endif /* MAGICKCORE_QUANTUM_DEPTH >= 16 */ +static const char* PngColorTypeToString(const unsigned int color_type) +{ + const char + *result = "Unknown"; + + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + result = "Gray"; + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + result = "Gray+Alpha"; + break; + case PNG_COLOR_TYPE_PALETTE: + result = "Palette"; + break; + case PNG_COLOR_TYPE_RGB: + result = "RGB"; + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + result = "RGB+Alpha"; + break; + } + + return result; +} + static int Magick_RenderingIntent_to_PNG_RenderingIntent(const RenderingIntent intent) { @@ -9294,7 +9321,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, if (logging != MagickFalse) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " Tentative PNG color type: %.20g",(double) ping_color_type); + " Tentative PNG color type: %s (%.20g)", + PngColorTypeToString(ping_color_type), + (double) ping_color_type); (void) LogMagickEvent(CoderEvent,GetMagickModule(), " image_info->type: %.20g",(double) image_info->type); @@ -9719,7 +9748,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " PNG color type: %d",ping_color_type); + " PNG color type: %s (%d)", PngColorTypeToString(ping_color_type), + ping_color_type); /* Initialize compression level and filtering. */ -- 2.40.0