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:06:15 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-12-03 16:06:15 +0000
commit30d0735d5fb1aad813380bc1d2ebf521070c9e20 (patch)
tree534d1da8857f3e3aaf58d76daa54a3caf3f9e43a /lib
parente304835519fb5985a426a3e097722d7439685f30 (diff)
downloadnetpbm-mirror-30d0735d5fb1aad813380bc1d2ebf521070c9e20.tar.gz
netpbm-mirror-30d0735d5fb1aad813380bc1d2ebf521070c9e20.tar.xz
netpbm-mirror-30d0735d5fb1aad813380bc1d2ebf521070c9e20.zip
Release 10.36.14
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@162 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
 }