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-11-28 16:30:41 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-11-28 16:30:41 +0000
commit67b79bdf31266d27f161ff7164357e434cdf8dd1 (patch)
treec1bf9177869c439343711307b246fbac98ea4eea /lib/libpnm3.c
parent42981754a445355aac8d62efdd276ba96fcdac03 (diff)
downloadnetpbm-mirror-67b79bdf31266d27f161ff7164357e434cdf8dd1.tar.gz
netpbm-mirror-67b79bdf31266d27f161ff7164357e434cdf8dd1.tar.xz
netpbm-mirror-67b79bdf31266d27f161ff7164357e434cdf8dd1.zip
Fix transparency optimization on PPM input
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@157 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpnm3.c')
-rw-r--r--lib/libpnm3.c26
1 files changed, 22 insertions, 4 deletions
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);
     }