about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-12-03 16:08:00 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-12-03 16:08:00 +0000
commit8e01637df59e9a366dede344bfb0df4343f540eb (patch)
tree983ca737ba523ba57e12b9c3b502db9f63c15619 /lib
parentacd527864efe6651f58a291ec6d707188ea20b29 (diff)
downloadnetpbm-mirror-8e01637df59e9a366dede344bfb0df4343f540eb.tar.gz
netpbm-mirror-8e01637df59e9a366dede344bfb0df4343f540eb.tar.xz
netpbm-mirror-8e01637df59e9a366dede344bfb0df4343f540eb.zip
Release 10.35.19
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@163 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r--lib/libpnm3.c24
-rw-r--r--lib/pnm.h3
2 files changed, 23 insertions, 4 deletions
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
 }