From 8e01637df59e9a366dede344bfb0df4343f540eb Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 3 Dec 2006 16:08:00 +0000 Subject: Release 10.35.19 git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@163 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libpnm3.c | 24 +++++++++++++++++++++--- lib/pnm.h | 3 ++- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libpnm3.c b/lib/libpnm3.c index c9c9a1b0..f10a7fca 100644 --- a/lib/libpnm3.c +++ b/lib/libpnm3.c @@ -383,11 +383,29 @@ pnm_promoteformatrow( xelrow, cols, maxval, format, newmaxval, newformat ) 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; } diff --git a/lib/pnm.h b/lib/pnm.h index d3b6f84f..ed6983f4 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); #ifdef __cplusplus } -- cgit 1.4.1