Index: /trunk/Ohana/src/kapa/Makefile
===================================================================
--- /trunk/Ohana/src/kapa/Makefile	(revision 5702)
+++ /trunk/Ohana/src/kapa/Makefile	(revision 5703)
@@ -52,5 +52,5 @@
 $(GDIR)/LoadPtext.$(ARCH).o		  $(GDIR)/DrawPtext.$(ARCH).o		\
 $(GDIR)/PSLabels.$(ARCH).o		  $(GDIR)/PSPtext.$(ARCH).o		\
-$(GDIR)/PNGit.$(ARCH).o                   $(GDIR)/PPMit.$(ARCH).o	        \
+$(GDIR)/PNGit.$(ARCH).o                   $(GDIR)/PPMit2.$(ARCH).o	        \
 $(GDIR)/DrawRotString.$(ARCH).o        	  $(GDIR)/RotFont.$(ARCH).o             \
 $(GDIR)/PSRotFont.$(ARCH).o
Index: /trunk/Ohana/src/kapa/graph/PPMit2.c
===================================================================
--- /trunk/Ohana/src/kapa/graph/PPMit2.c	(revision 5703)
+++ /trunk/Ohana/src/kapa/graph/PPMit2.c	(revision 5703)
@@ -0,0 +1,54 @@
+# include "Ximage.h"
+# include <png.h>
+# include "bDraw.h"
+
+int PPMit () {
+
+  FILE *f;
+  char *line, filename[1024];
+  int Nbytes, status, dx, dy, i, j, Npalette, color;
+  png_color *palette;
+
+  bDrawBuffer *buffer;
+
+  /* expect a line telling the number of bytes and a filename */
+  status = read (sock, filename, 16);
+  filename[16] = 0;
+  sscanf (filename, "%*s %d", &Nbytes);
+  status = read (sock, filename, Nbytes);
+  filename[status] = 0; /* make the string easy to parse */
+
+  f = fopen (filename, "w");
+  if (f == (FILE *) NULL) {
+    fprintf (stderr, "can't open output file %s\n", filename);
+    return (TRUE);  /* true because otherwise it quits kapa! */
+  }
+  
+  palette = MakePNGPalette (&Npalette);
+
+  dx = graphic.dx;
+  dy = graphic.dy;
+  
+  fprintf (f, "P6\n");
+  fprintf (f, "%d %d\n", dx, dy);
+  fprintf (f, "255\n");
+
+  buffer = bDrawIt ();
+
+  ALLOCATE (line, char, 3*dx);
+
+  for (i = 0; i < dy; i++) {
+    for (j = 0; j < dx; j++) {
+      color = buffer[0].pixels[i][j];
+      line[3*j + 0] = palette[color].red;
+      line[3*j + 1] = palette[color].green;
+      line[3*j + 2] = palette[color].blue;
+    }
+    fwrite (line, 3, dx, f);
+  }
+  fclose (f);
+  
+  bDrawBufferFree (buffer);
+  return (TRUE);
+
+}
Index: /trunk/Ohana/src/kapa/setup/MakeColormap.c
===================================================================
--- /trunk/Ohana/src/kapa/setup/MakeColormap.c	(revision 5702)
+++ /trunk/Ohana/src/kapa/setup/MakeColormap.c	(revision 5703)
@@ -63,4 +63,33 @@
 }
 
+# if (0)
+int *MakePPMPalette (int *Npalette, int color) {
+
+  int i, *palette;
+  float red, green, blue;
+
+  ALLOCATE (palette, int, NGRAPHCOLORS);
+
+  /* define the palette */
+  for (i = 0; i < NGRAPHCOLORS; i++) {
+    sscanf (GRAPHCOLORS[i][2], "%f %f %f", &red, &green, &blue);
+    switch (color) {
+      case 0:
+	palette[i] = (0xff * red);
+	break;
+      case 1:
+	palette[i] = (0xff * green);
+	break;
+      case 2:
+	palette[i] = (0xff * blue);
+	break;
+      default:
+	break;
+  }
+  *Npalette = NGRAPHCOLORS;
+  return (palette);
+}
+# endif
+
 void MakeColormap (int argc, char **argv) {
 
