about summary refs log tree commit diff
path: root/lib/libpnm3.c
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/libpnm3.c
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/libpnm3.c')
-rw-r--r--lib/libpnm3.c24
1 files changed, 21 insertions, 3 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;
 }