diff options
-rw-r--r-- | converter/other/pnmtopng.c | 6 | ||||
-rw-r--r-- | doc/HISTORY | 2 | ||||
-rw-r--r-- | lib/libpnm3.c | 26 | ||||
-rw-r--r-- | lib/pnm.h | 3 |
4 files changed, 29 insertions, 8 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index b83cbbcf..30966fa2 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -962,7 +962,7 @@ analyzeAlpha(FILE * const ifp, gray const alphaMaxval, bool * const allOpaqueP, bool * const singleColorIsTransP, - pixel* const alphaTranscolorP) { + pixel * const alphaTranscolorP) { /*---------------------------------------------------------------------------- Get information about the alpha mask, in combination with the masked image, that Caller can use to choose the most efficient way to @@ -993,13 +993,13 @@ analyzeAlpha(FILE * const ifp, */ foundTransparentPixel = FALSE; /* initial assumption */ pm_seek2(ifp, &rasterPos, sizeof(rasterPos)); - for (row = 0 ; row < rows && !foundTransparentPixel ; ++row) { + for (row = 0; row < rows && !foundTransparentPixel; ++row) { int col; pnm_readpnmrow(ifp, xelrow, cols, maxval, format); for (col = 0; col < cols && !foundTransparentPixel; ++col) { if (alphaMask[row][col] == 0) { foundTransparentPixel = TRUE; - transcolor = xeltopixel(xelrow[col]); + transcolor = pnm_xeltopixel(xelrow[col], format); } } } diff --git a/doc/HISTORY b/doc/HISTORY index a4d9d757..239bb919 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,6 +6,8 @@ CHANGE HISTORY not yet BJH Release 10.37.0 + pnmtopng: fix transparency optimization on PPM input. + pnmrotate: fix -background option with PGM/PBM input. pnmshear: add -background. Thanks Erik Auerswald diff --git a/lib/libpnm3.c b/lib/libpnm3.c index c7951546..4df8041c 100644 --- a/lib/libpnm3.c +++ b/lib/libpnm3.c @@ -337,12 +337,30 @@ pnm_promoteformatrow( xel* xelrow, int cols, xelval maxval, int format, xelval n pixel -xeltopixel(xel const inputxel) { +pnm_xeltopixel(xel const inputxel, + int const format) { pixel outputpixel; - PPM_ASSIGN(outputpixel, - PNM_GET1(inputxel), PNM_GET1(inputxel), PNM_GET1(inputxel)); + switch (PNM_FORMAT_TYPE(format)) { + case PPM_TYPE: + PPM_ASSIGN(outputpixel, + PPM_GETR(inputxel), + PPM_GETG(inputxel), + PPM_GETB(inputxel)); + break; + case PGM_TYPE: + case PBM_TYPE: + PPM_ASSIGN(outputpixel, + PNM_GET1(inputxel), + PNM_GET1(inputxel), + PNM_GET1(inputxel)); + break; + default: + pm_error("Invalid format code %d passed to pnm_xeltopixel()", + format); + } + return outputpixel; } @@ -381,7 +399,7 @@ pnm_parsecolorxel(const char * const colorName, colorName); break; default: - pm_error("Invalid format code %d passed to pnm_parsecolor()", + pm_error("Invalid format code %d passed to pnm_parsecolorxel()", format); } diff --git a/lib/pnm.h b/lib/pnm.h index 354eacf9..94d4ff85 100644 --- a/lib/pnm.h +++ b/lib/pnm.h @@ -124,7 +124,8 @@ pnm_promoteformatrow(xel* xelrow, int cols, xelval maxval, int format, xelval newmaxval, int newformat); pixel -xeltopixel(xel const inputxel); +pnm_xeltopixel(xel const inputxel, + int const format); xel pnm_parsecolorxel(const char * const colorName, |