From 67b79bdf31266d27f161ff7164357e434cdf8dd1 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Tue, 28 Nov 2006 16:30:41 +0000 Subject: Fix transparency optimization on PPM input git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@157 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libpnm3.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'lib/libpnm3.c') 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); } -- cgit 1.4.1