about summary refs log tree commit diff
path: root/converter/other/pnmtopalm
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/pnmtopalm')
-rw-r--r--converter/other/pnmtopalm/Makefile9
-rw-r--r--converter/other/pnmtopalm/gen_palm_colormap.c48
-rw-r--r--converter/other/pnmtopalm/palmcolor8.map458
-rw-r--r--converter/other/pnmtopalm/palmtopnm.c1
-rw-r--r--converter/other/pnmtopalm/pnmtopalm.c1
5 files changed, 283 insertions, 234 deletions
diff --git a/converter/other/pnmtopalm/Makefile b/converter/other/pnmtopalm/Makefile
index 4a8fa02a..7f99f95a 100644
--- a/converter/other/pnmtopalm/Makefile
+++ b/converter/other/pnmtopalm/Makefile
@@ -5,7 +5,7 @@ endif
 SUBDIR = converter/other/pnmtopalm
 VPATH=.:$(SRCDIR)/$(SUBDIR)
 
-include $(BUILDDIR)/Makefile.config
+include $(BUILDDIR)/config.mk
 
 BINARIES = palmtopnm pnmtopalm
 SCRIPTS =
@@ -16,7 +16,7 @@ DATAFILES = palmcolor8.map palmgray1.map palmgray2.map palmgray4.map
 
 all: $(BINARIES)
 
-include $(SRCDIR)/Makefile.common
+include $(SRCDIR)/common.mk
 
 LIBOPTS = $(shell $(LIBOPT) $(NETPBMLIB))
 
@@ -24,8 +24,9 @@ $(BINARIES): %: %.o palmcolormap.o $(NETPBMLIB) $(LIBOPT)
 	$(LD) -o $@ $< palmcolormap.o $(LIBOPTS) \
 	  $(MATHLIB) $(LDFLAGS) $(LDLIBS) $(RPATH) $(LADD)
 
-gen_palm_colormap : $(SUBDIR)/gen_palm_colormap.c palmcolormap.o
-	$(CC) $(INCLUDES) $(CFLAGS) -o $@ $< palmcolormap.o \
+gen_palm_colormap : % : %.c palmcolormap.o
+	$(CC) -I importinc $(CPPFLAGS) $(CFLAGS) -o $@ \
+	  $< palmcolormap.o \
 	  $(LIBOPTS) $(MATHLIB) $(LDFLAGS) $(LDLIBS) $(LADD)
 
 
diff --git a/converter/other/pnmtopalm/gen_palm_colormap.c b/converter/other/pnmtopalm/gen_palm_colormap.c
index 4b65e631..c7172c6b 100644
--- a/converter/other/pnmtopalm/gen_palm_colormap.c
+++ b/converter/other/pnmtopalm/gen_palm_colormap.c
@@ -1,24 +1,46 @@
 /* gen_palm_colormap.c - generate a ppm file containing the default Palm colormap
  *
- * Bill Janssen  <bill@janssen.org>
+ * Based on an earlier version by Bill Janssen  <bill@janssen.org>
  */
 
-#include "pnm.h"
+#include "ppm.h"
+#include "pm_c_util.h"
 
 #include "palm.h"
 
-int main( int argc, char **argv ) {
+int
+main(int     argc,
+     char ** argv) {
 
-  int i;
-  Color_s current;
-  Colormap default_map = palmcolor_build_default_8bit_colormap ();
+    Colormap defaultMap;
+    unsigned int i;
+    pixel pix;
+    
+    defaultMap = palmcolor_build_default_8bit_colormap();
+    qsort (defaultMap->color_entries, defaultMap->ncolors,
+           sizeof(Color_s), palmcolor_compare_indices);
 
-  printf("P3\n%d 1\n255\n", default_map->ncolors);
-  for (i = 0;  i < default_map->ncolors;  i++) {
-    current = default_map->color_entries[i];
-    printf ("%d %d %d\n", (current & 0xFF0000) >> 16, (current & 0xFF00) >> 8, (current & 0xFF));
-    /* printf ("%x:  %d %d %d\n", (current & 0xFF000000) >> 24, (current & 0xFF0000) >> 16, (current & 0xFF00) >> 8, (current & 0xFF)); */
-  };
-  return 0;
+    ppm_writeppminit(stdout, 256, 1, 255, TRUE);
+
+    for (i = 0; i < defaultMap->ncolors; ++i) {
+        Color_s const current = defaultMap->color_entries[i];
+
+        PPM_ASSIGN(pix,
+                   (current >> 16) & 0xff,
+                   (current >>  8) & 0xff,
+                   (current >>  0) & 0xff);
+
+        ppm_writeppmrow(stdout, &pix, 1, 255, TRUE);
+    }
+
+    /* palmcolor_build_default_8bit_colormap() builds a map of the 231 default
+     * palm colors and 1 extra black pixel. Add another 24 extra black pixels
+     * as per spec. */
+    PPM_ASSIGN(pix, 0, 0, 0);
+    for (i = 0; i < 256 - defaultMap->ncolors; ++i) {
+        ppm_writeppmrow(stdout, &pix, 1, 255, TRUE);
+    }
+
+    return 0;
 }
 
diff --git a/converter/other/pnmtopalm/palmcolor8.map b/converter/other/pnmtopalm/palmcolor8.map
index 2e054616..a4840118 100644
--- a/converter/other/pnmtopalm/palmcolor8.map
+++ b/converter/other/pnmtopalm/palmcolor8.map
@@ -1,235 +1,259 @@
 P3
-232 1
+256 1
 255
-0 0 0
-0 0 0
-0 0 51
-0 0 102
-0 0 153
-0 0 204
+255 255 255
+255 204 255
+255 153 255
+255 102 255
+255 51 255
+255 0 255
+255 255 204
+255 204 204
+255 153 204
+255 102 204
+255 51 204
+255 0 204
+255 255 153
+255 204 153
+255 153 153
+255 102 153
+255 51 153
+255 0 153
+204 255 255
+204 204 255
+204 153 255
+204 102 255
+204 51 255
+204 0 255
+204 255 204
+204 204 204
+204 153 204
+204 102 204
+204 51 204
+204 0 204
+204 255 153
+204 204 153
+204 153 153
+204 102 153
+204 51 153
+204 0 153
+153 255 255
+153 204 255
+153 153 255
+153 102 255
+153 51 255
+153 0 255
+153 255 204
+153 204 204
+153 153 204
+153 102 204
+153 51 204
+153 0 204
+153 255 153
+153 204 153
+153 153 153
+153 102 153
+153 51 153
+153 0 153
+102 255 255
+102 204 255
+102 153 255
+102 102 255
+102 51 255
+102 0 255
+102 255 204
+102 204 204
+102 153 204
+102 102 204
+102 51 204
+102 0 204
+102 255 153
+102 204 153
+102 153 153
+102 102 153
+102 51 153
+102 0 153
+51 255 255
+51 204 255
+51 153 255
+51 102 255
+51 51 255
+51 0 255
+51 255 204
+51 204 204
+51 153 204
+51 102 204
+51 51 204
+51 0 204
+51 255 153
+51 204 153
+51 153 153
+51 102 153
+51 51 153
+51 0 153
+0 255 255
+0 204 255
+0 153 255
+0 102 255
+0 51 255
 0 0 255
-0 51 0
-0 51 51
-0 51 102
-0 51 153
+0 255 204
+0 204 204
+0 153 204
+0 102 204
 0 51 204
-0 51 255
-0 102 0
-0 102 51
-0 102 102
+0 0 204
+0 255 153
+0 204 153
+0 153 153
 0 102 153
-0 102 204
-0 102 255
-0 128 0
-0 128 128
-0 153 0
-0 153 51
+0 51 153
+0 0 153
+255 255 102
+255 204 102
+255 153 102
+255 102 102
+255 51 102
+255 0 102
+255 255 51
+255 204 51
+255 153 51
+255 102 51
+255 51 51
+255 0 51
+255 255 0
+255 204 0
+255 153 0
+255 102 0
+255 51 0
+255 0 0
+204 255 102
+204 204 102
+204 153 102
+204 102 102
+204 51 102
+204 0 102
+204 255 51
+204 204 51
+204 153 51
+204 102 51
+204 51 51
+204 0 51
+204 255 0
+204 204 0
+204 153 0
+204 102 0
+204 51 0
+204 0 0
+153 255 102
+153 204 102
+153 153 102
+153 102 102
+153 51 102
+153 0 102
+153 255 51
+153 204 51
+153 153 51
+153 102 51
+153 51 51
+153 0 51
+153 255 0
+153 204 0
+153 153 0
+153 102 0
+153 51 0
+153 0 0
+102 255 102
+102 204 102
+102 153 102
+102 102 102
+102 51 102
+102 0 102
+102 255 51
+102 204 51
+102 153 51
+102 102 51
+102 51 51
+102 0 51
+102 255 0
+102 204 0
+102 153 0
+102 102 0
+102 51 0
+102 0 0
+51 255 102
+51 204 102
+51 153 102
+51 102 102
+51 51 102
+51 0 102
+51 255 51
+51 204 51
+51 153 51
+51 102 51
+51 51 51
+51 0 51
+51 255 0
+51 204 0
+51 153 0
+51 102 0
+51 51 0
+51 0 0
+0 255 102
+0 204 102
 0 153 102
-0 153 153
-0 153 204
-0 153 255
-0 204 0
+0 102 102
+0 51 102
+0 0 102
+0 255 51
 0 204 51
-0 204 102
-0 204 153
-0 204 204
-0 204 255
+0 153 51
+0 102 51
+0 51 51
+0 0 51
 0 255 0
-0 255 51
-0 255 102
-0 255 153
-0 255 204
-0 255 255
+0 204 0
+0 153 0
+0 102 0
+0 51 0
 17 17 17
 34 34 34
-51 0 0
-51 0 51
-51 0 102
-51 0 153
-51 0 204
-51 0 255
-51 51 0
-51 51 51
-51 51 102
-51 51 153
-51 51 204
-51 51 255
-51 102 0
-51 102 51
-51 102 102
-51 102 153
-51 102 204
-51 102 255
-51 153 0
-51 153 51
-51 153 102
-51 153 153
-51 153 204
-51 153 255
-51 204 0
-51 204 51
-51 204 102
-51 204 153
-51 204 204
-51 204 255
-51 255 0
-51 255 51
-51 255 102
-51 255 153
-51 255 204
-51 255 255
 68 68 68
 85 85 85
-102 0 0
-102 0 51
-102 0 102
-102 0 153
-102 0 204
-102 0 255
-102 51 0
-102 51 51
-102 51 102
-102 51 153
-102 51 204
-102 51 255
-102 102 0
-102 102 51
-102 102 102
-102 102 153
-102 102 204
-102 102 255
-102 153 0
-102 153 51
-102 153 102
-102 153 153
-102 153 204
-102 153 255
-102 204 0
-102 204 51
-102 204 102
-102 204 153
-102 204 204
-102 204 255
-102 255 0
-102 255 51
-102 255 102
-102 255 153
-102 255 204
-102 255 255
 119 119 119
-128 0 0
-128 0 128
 136 136 136
-153 0 0
-153 0 51
-153 0 102
-153 0 153
-153 0 204
-153 0 255
-153 51 0
-153 51 51
-153 51 102
-153 51 153
-153 51 204
-153 51 255
-153 102 0
-153 102 51
-153 102 102
-153 102 153
-153 102 204
-153 102 255
-153 153 0
-153 153 51
-153 153 102
-153 153 153
-153 153 204
-153 153 255
-153 204 0
-153 204 51
-153 204 102
-153 204 153
-153 204 204
-153 204 255
-153 255 0
-153 255 51
-153 255 102
-153 255 153
-153 255 204
-153 255 255
 170 170 170
 187 187 187
-192 192 192
-204 0 0
-204 0 51
-204 0 102
-204 0 153
-204 0 204
-204 0 255
-204 51 0
-204 51 51
-204 51 102
-204 51 153
-204 51 204
-204 51 255
-204 102 0
-204 102 51
-204 102 102
-204 102 153
-204 102 204
-204 102 255
-204 153 0
-204 153 51
-204 153 102
-204 153 153
-204 153 204
-204 153 255
-204 204 0
-204 204 51
-204 204 102
-204 204 153
-204 204 204
-204 204 255
-204 255 0
-204 255 51
-204 255 102
-204 255 153
-204 255 204
-204 255 255
 221 221 221
 238 238 238
-255 0 0
-255 0 51
-255 0 102
-255 0 153
-255 0 204
-255 0 255
-255 51 0
-255 51 51
-255 51 102
-255 51 153
-255 51 204
-255 51 255
-255 102 0
-255 102 51
-255 102 102
-255 102 153
-255 102 204
-255 102 255
-255 153 0
-255 153 51
-255 153 102
-255 153 153
-255 153 204
-255 153 255
-255 204 0
-255 204 51
-255 204 102
-255 204 153
-255 204 204
-255 204 255
-255 255 0
-255 255 51
-255 255 102
-255 255 153
-255 255 204
-255 255 255
+192 192 192
+128 0 0
+128 0 128
+0 128 0
+0 128 128
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
diff --git a/converter/other/pnmtopalm/palmtopnm.c b/converter/other/pnmtopalm/palmtopnm.c
index ee43be7a..88088817 100644
--- a/converter/other/pnmtopalm/palmtopnm.c
+++ b/converter/other/pnmtopalm/palmtopnm.c
@@ -15,6 +15,7 @@
 #include <string.h>
 #include <assert.h>
 
+#include "pm_c_util.h"
 #include "pnm.h"
 #include "shhopt.h"
 #include "mallocvar.h"
diff --git a/converter/other/pnmtopalm/pnmtopalm.c b/converter/other/pnmtopalm/pnmtopalm.c
index d5f79619..90737b78 100644
--- a/converter/other/pnmtopalm/pnmtopalm.c
+++ b/converter/other/pnmtopalm/pnmtopalm.c
@@ -21,6 +21,7 @@
 #include <assert.h>
 #include <limits.h>
 
+#include "pm_c_util.h"
 #include "pnm.h"
 #include "palm.h"
 #include "shhopt.h"