diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2008-07-13 23:34:49 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2008-07-13 23:34:49 +0000 |
commit | 39a3b6d0fd7821eef8ec9392bdbfdb83bb356d1e (patch) | |
tree | 55515eeb68acbad8db7d29c2f7471f9be6d753ec | |
parent | 09f70ec67186bb10dbd252650210bff2daa70ec7 (diff) | |
download | netpbm-mirror-39a3b6d0fd7821eef8ec9392bdbfdb83bb356d1e.tar.gz netpbm-mirror-39a3b6d0fd7821eef8ec9392bdbfdb83bb356d1e.tar.xz netpbm-mirror-39a3b6d0fd7821eef8ec9392bdbfdb83bb356d1e.zip |
Release 10.35.47
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@676 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | Makefile.version | 2 | ||||
-rw-r--r-- | converter/other/pngtopnm.c | 32 | ||||
-rw-r--r-- | doc/HISTORY | 5 |
3 files changed, 23 insertions, 16 deletions
diff --git a/Makefile.version b/Makefile.version index 9a21415e..69da8e6a 100644 --- a/Makefile.version +++ b/Makefile.version @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 35 -NETPBM_POINT_RELEASE = 46 +NETPBM_POINT_RELEASE = 47 diff --git a/converter/other/pngtopnm.c b/converter/other/pngtopnm.c index bb8afb8d..a393f966 100644 --- a/converter/other/pngtopnm.c +++ b/converter/other/pngtopnm.c @@ -200,6 +200,14 @@ _get_png_val (png_byte ** const pp, +static bool +isGrayscale(pngcolor const color) { + + return color.r == color.g && color.r == color.b; +} + + + static void setXel(xel * const xelP, pngcolor const foreground, @@ -745,10 +753,12 @@ imageHasColor(png_info * const info_ptr) { static void determineOutputType(png_info * const info_ptr, enum alpha_handling const alphaHandling, + pngcolor const bgColor, xelval const maxval, int * const pnmTypeP) { - if (alphaHandling != ALPHA_ONLY && imageHasColor(info_ptr)) + if (alphaHandling != ALPHA_ONLY && + (imageHasColor(info_ptr) || !isGrayscale(bgColor))) *pnmTypeP = PPM_TYPE; else { if (maxval > 1) @@ -778,19 +788,11 @@ getBackgroundColor(png_info * const info_ptr, which is a bit arbitrary. */ pixel const backcolor = ppm_parsecolor(requestedColor, maxval); - switch (info_ptr->color_type) { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - bgColorP->r = bgColorP->g = bgColorP->b = PNM_GET1(backcolor); - break; - case PNG_COLOR_TYPE_PALETTE: - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - bgColorP->r = PPM_GETR(backcolor); - bgColorP->g = PPM_GETG(backcolor); - bgColorP->b = PPM_GETB(backcolor); - break; - } + + bgColorP->r = PPM_GETR(backcolor); + bgColorP->g = PPM_GETG(backcolor); + bgColorP->b = PPM_GETB(backcolor); + } else if (info_ptr->valid & PNG_INFO_bKGD) { /* didn't manage to get libpng to work (bugs?) concerning background processing, therefore we do our own. @@ -1049,7 +1051,7 @@ convertpng(FILE * const ifp, } } - determineOutputType(info_ptr, cmdline.alpha, maxval, &pnm_type); + determineOutputType(info_ptr, cmdline.alpha, bgColor, maxval, &pnm_type); writePnm(stdout, maxval, pnm_type, info_ptr, png_image, bgColor, cmdline.alpha, totalgamma); diff --git a/doc/HISTORY b/doc/HISTORY index a6ae2a0e..84bb963d 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,11 @@ Netpbm. CHANGE HISTORY -------------- +08.07.13 BJH Release 10.35.47 + + pngtopnm: fix bug: when background is color, output + should be PPM. + 08.06.22 BJH Release 10.35.46 pbmtext: fix buffer overrun with tab characters. |