Index: /branches/eam_branch_20071222/Ohana/src/kapa2/Makefile
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/Makefile	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/Makefile	(revision 15925)
@@ -77,5 +77,5 @@
 $(SRC)/bDrawOverlay.$(ARCH).o             $(SRC)/ButtonFunctions.$(ARCH).o    \
 $(SRC)/PSimage.$(ARCH).o                  $(SRC)/PSPixmap.$(ARCH).o           \
-$(SRC)/PSOverlay.$(ARCH).o
+$(SRC)/PSOverlay.$(ARCH).o                $(SRC)/SetChannel.$(ARCH).o
 
 OBJ  =  $(KAPA)
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/include/buttons.h
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/include/buttons.h	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/include/buttons.h	(revision 15925)
@@ -47,7 +47,7 @@
    0x80, 0xef, 0x03, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00};
-#define puns_width 25
-#define puns_height 25
-static char puns_bits[] = {
+#define heat_width 25
+#define heat_height 25
+static char heat_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xd8, 0x01,
    0x00, 0x0c, 0x37, 0x00, 0xf8, 0xc9, 0x6f, 0x00, 0x0c, 0xde, 0xf0, 0x00,
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h	(revision 15925)
@@ -9,4 +9,8 @@
  | StructureNotifyMask \
  | PointerMotionMask)
+
+# define NCHANNELS 3
+# define NPIXELS_DYNAMIC 128
+# define NPIXELS_STATIC 1024
 
 # define PAD1  3
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h	(revision 15925)
@@ -140,5 +140,5 @@
 
 int           Center              PROTO(());
-void          Remap               PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
+void          Remap               PROTO((Graphic *graphic, KapaImageWidget *image));
 void          Remap8              PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
 void          Remap16             PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
@@ -147,5 +147,6 @@
 int           LoadPicture         PROTO((int sock));
 
-KapaImageWidget *InitImage        PROTO(());
+KapaImageWidget *InitImageWidget  PROTO(());
+int           InitImageChannel    PROTO((KapaImageChannel *channel));
 void          FreeImage           PROTO((KapaImageWidget *image));
 void          SetImageSize        PROTO((Section *section));
@@ -179,5 +180,5 @@
 /* Button Functions */
 int           greycolors	  PROTO((Graphic *graphic, KapaImageWidget *image));
-int	      puns		  PROTO((Graphic *graphic, KapaImageWidget *image));
+int	      heat		  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      rainbow		  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      Recenter		  PROTO((Graphic *graphic, KapaImageWidget *image));
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h	(revision 15925)
@@ -2,11 +2,11 @@
 /**************** Graphic carries X info around ****************/
 typedef struct {
-  Display       *display;
-  int            screen;
+  Display       *display;     // X display pointer
+  int            screen;      // X screen number
   int            depth;
   Window         window;
   Visual        *visual;
-  int            visualclass;
-  int            Nbits;
+  int            visualclass; // is visual dynamic? (XXX change name?)
+  int            Nbits;	      // pixel depth in bits (8, 16, 24, 32)
   GC             gc;
   XFontStruct   *font;
@@ -14,13 +14,16 @@
   int            x,  y;
   unsigned int   dx, dy;
-  XColor         cmap[1024];
+  XColor        *cmap;
   Colormap       colormap;
-  unsigned long  fore;
-  unsigned long  back;
-  unsigned long  *color;
-  unsigned long  pixels[1024];
-  unsigned long  overlay_color[NOVERLAYS];
-  int Npixels;
+  unsigned long *color;      // graph plotting colors
   int Ncolors;
+
+  unsigned long *pixels;     // image pixel colors
+  int Npixels;		      // number of pixels
+
+  unsigned long  fore;	      // basic foreground color 
+  unsigned long  back;	      // basic background color
+
+  unsigned long  overlay_color[NOVERLAYS]; // image plotting colors 
 } Graphic;
 
@@ -125,4 +128,15 @@
 } KapaGraphWidget;
 
+typedef struct {
+  // data associated with this image element
+  Matrix   matrix;         /* data for picture */
+  double   zero, range;    /* zero, range for picture to cmap */
+  double   max, min;       /* zero, range for data to z-value */
+  double   start, slope;   /* zero, range for cmap to pixels */
+  Coords   coords;
+  char     file[1024];     /* name of file */
+  char     name[1024];     /* name of buffer */
+} KapaImageChannel;
+
 // a single image in the display window
 typedef struct {
@@ -139,5 +153,5 @@
   Button   grey_button;
   Button   rainbow_button;
-  Button    puns_button;
+  Button   heat_button;
   Button   overlay_button[NOVERLAYS];
 
@@ -149,17 +163,14 @@
   int      DecimalDegrees;
 
-  // data associated with this image element
+  double   X, Y;           /* image pixel at screen center */
+  int      expand;         /* zoomscale */
+  double   x, y, z;        /* last pointer coords */
+
   Overlay  overlay[NOVERLAYS];
   Overlay  tickmarks;
-  Matrix   matrix;         /* data for picture */
-  double   X, Y;           /* image pixel at screen center */
-  int      expand;         /* zoomscale */
-  double   zero, range;    /* zero, range for picture to cmap */
-  double   max, min;       /* zero, range for data to z-value */
-  double   start, slope;   /* zero, range for cmap to pixels */
-  double   x, y, z;        /* last pointer coords */
-  Coords   coords;
-  char     file[1024];     /* name of file */
-  char     name[1024];  /* name of buffer */
+
+  unsigned short   *pixmap;   // lookup table for image pixel value to pixel index
+  KapaImageChannel *image;
+  KapaImageChannel channel[NCHANNELS];
 } KapaImageWidget;
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/ButtonFunctions.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 15925)
@@ -2,5 +2,5 @@
 
 static char *GREY = "greyscale";
-static char *PUNS = "Puns";
+static char *HEAT = "Heat";
 static char *RAINBOW = "Rainbow";
 
@@ -18,5 +18,5 @@
   SetColormap (name);
   CreateColorbar (image, graphic);
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   CreateZoom (image, graphic, 0, 0); 
   Refresh ();
@@ -25,10 +25,10 @@
 }
 
-int puns (Graphic *graphic, KapaImageWidget *image) {
+int heat (Graphic *graphic, KapaImageWidget *image) {
   char *name;
-  name = PUNS;
+  name = HEAT;
   SetColormap (name);
   CreateColorbar (image, graphic);
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   CreateZoom (image, graphic, 0, 0); 
   Refresh ();
@@ -42,5 +42,5 @@
   SetColormap (name);
   CreateColorbar (image, graphic);
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   CreateZoom (image, graphic, 0, 0); 
   Refresh ();
@@ -54,5 +54,5 @@
   image[0].Y = 0;
  
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   Refresh ();
   FlushDisplay (graphic[0].display);
@@ -64,5 +64,5 @@
 
   image[0].expand = 1;
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   Refresh ();
   FlushDisplay (graphic[0].display);
@@ -77,5 +77,5 @@
   image[0].expand = 1;
  
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   Refresh ();
   FlushDisplay (graphic[0].display);
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CSaveOverlay.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CSaveOverlay.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CSaveOverlay.c	(revision 15925)
@@ -24,19 +24,19 @@
   for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
     if (image[0].overlay[N].objects[i].type == KII_OVERLAY_LINE) {
-      XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].coords);
+      XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].image[0].coords);
       x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx;
       y1 = image[0].overlay[N].objects[i].y + image[0].overlay[N].objects[i].dy;
-      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].coords);
+      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords);
       dra = (ra1 - ra);
       ddec = (dec1 - dec);
     } else {
-      XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].coords);
+      XY_to_RD (&ra, &dec, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].image[0].coords);
       x1 = image[0].overlay[N].objects[i].x;
       y1 = image[0].overlay[N].objects[i].y + image[0].overlay[N].objects[i].dy;
-      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].coords);
+      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords);
       ddec = fabs (dec1 - dec);
       x1 = image[0].overlay[N].objects[i].x + image[0].overlay[N].objects[i].dx;
       y1 = image[0].overlay[N].objects[i].y;
-      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].coords);
+      XY_to_RD (&ra1, &dec1, x1, y1, &image[0].image[0].coords);
       dra = cos (dec*RAD_DEG) * fabs (ra1 - ra);
     }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Center.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Center.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Center.c	(revision 15925)
@@ -16,6 +16,6 @@
   if (image == NULL) return (TRUE);
 
-  image[0].X = 0.5*image[0].matrix.Naxis[0] - X;
-  image[0].Y = 0.5*image[0].matrix.Naxis[1] - Y;
+  image[0].X = 0.5*image[0].image[0].matrix.Naxis[0] - X;
+  image[0].Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y;
   if ((zoom != 0) && (zoom != -1)) {
     image[0].expand = zoom;
@@ -23,5 +23,5 @@
 
   if (USE_XWINDOW) {
-    Remap (graphic, image, &image[0].matrix);
+    Remap (graphic, image);
     Refresh ();
     XFlush (graphic[0].display);
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckButtons.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckButtons.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckButtons.c	(revision 15925)
@@ -1,7 +1,3 @@
 # include "Ximage.h"
-# define PAD_X 10
-# define PAD_Y 10
-# define NPLANES 1
-# define NPIXELS 255
 
 /******** Here we test the Buttons specific to this program  *******/
@@ -21,6 +17,6 @@
     button = &image[0].rainbow_button;
 
-  if (InButton (event, &image[0].puns_button)) 
-    button = &image[0].puns_button;
+  if (InButton (event, &image[0].heat_button)) 
+    button = &image[0].heat_button;
 
   if (InButton (event, &image[0].PS_button)) 
@@ -39,5 +35,4 @@
 }
 
-
 /* To define a button, you must:
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckPipe.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckPipe.c	(revision 15925)
@@ -268,4 +268,10 @@
   }
 
+  if (!strcmp (word, "CHAN")) {
+    status = SetChannel (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (status);
+  }
+
   if (!strcmp (word, "SAVE")) {
     status = SaveOverlay (sock);
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckVisual.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckVisual.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckVisual.c	(revision 15925)
@@ -1,4 +1,3 @@
 # include "Ximage.h"
-# define NPIXELS 64
 
 /* DirectColor doesn't seem to work, even though it is available:
@@ -11,5 +10,5 @@
 
   int i, Nfound, N;
-  int col, def, dyn;
+  int isColor, isDefault, isDynamic;
   XVisualInfo *visual_list, visual_temp;
   unsigned long planes[3];
@@ -20,8 +19,8 @@
     fprintf (stderr, "DirectColor: %d\n", DirectColor);
     fprintf (stderr, "PseudoColor: %d\n", PseudoColor);
-    fprintf (stderr, "TrueColor: %d\n", TrueColor);
-    fprintf (stderr, "GrayScale: %d\n", GrayScale);
+    fprintf (stderr, "TrueColor:   %d\n", TrueColor);
+    fprintf (stderr, "GrayScale:   %d\n", GrayScale);
     fprintf (stderr, "StaticColor: %d\n", StaticColor);
-    fprintf (stderr, "StaticGray: %d\n", StaticGray);
+    fprintf (stderr, "StaticGray:  %d\n", StaticGray);
   }
 
@@ -42,86 +41,65 @@
   }
 
-  col = def = dyn = FALSE;
+  // set these based on selected visual
+  isColor = isDefault = isDynamic = FALSE;
+
+  // attempt to select the most desirable type of visual: Default as PseudoColor (XXX is it still true?)
   if (DEBUG) fprintf (stderr, "default visual class is %d\n", visual_list[i].class);
-  switch (visual_list[i].class) {
-  case PseudoColor:
-    col = def = dyn = TRUE;
+  if (visual_list[i].class == PseudoColor) {
+    isColor = isDefault = isDynamic = TRUE;
     graphic[0].visual = visual_list[i].visual;
     graphic[0].visualclass = TRUE;
     goto test_pixels;
-    break;
-  default:
-    break;
   }
 
-  for (i = 0; i < Nfound; i++) {
-    switch (visual_list[i].class) {
-    case PseudoColor:
-      if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
-      col = dyn = TRUE;
-      if (graphic[0].visual == visual_list[i].visual) {
-	def = TRUE;
-      } else {
-	graphic[0].visual = visual_list[i].visual;
-      }
-      graphic[0].visualclass = TRUE;
-      goto test_pixels;
-      break;
-    default:
-      break;
-    }
+  // attempt to select the most desirable type of visual: PseudoColor (XXX is it still true?)
+  for (i = 0; (i < Nfound) && (visual_list[i].class != PseudoColor); i++);
+  if (i != Nfound) {
+    isColor = isDynamic = TRUE;
+    if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
+    isDefault = (graphic[0].visual == visual_list[i].visual);
+    graphic[0].visual = visual_list[i].visual;
+    graphic[0].visualclass = TRUE;
+    goto test_pixels;
   }
 
-  for (i = 0; i < Nfound; i++) {
-    switch (visual_list[i].class) {
-    case GrayScale:
-      if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
-      dyn = TRUE;
-      if (graphic[0].visual == visual_list[i].visual) {
-	def = TRUE;
-      } else {
-	graphic[0].visual = visual_list[i].visual;
-      }
-      graphic[0].visualclass = TRUE;
-      goto test_pixels;
-      break;
-    default:
-      break;
-    }
+  // attempt to select the most desirable type of visual: GrayScale (XXX is it still true?)
+  for (i = 0; (i < Nfound) && (visual_list[i].class != GrayScale); i++);
+  if (i != Nfound) {
+    isDynamic = TRUE;
+    if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
+    isDefault = (graphic[0].visual == visual_list[i].visual);
+    graphic[0].visual = visual_list[i].visual;
+    graphic[0].visualclass = TRUE;
+    goto test_pixels;
   }
 
+  // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?)
   for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++);
   if (i != Nfound) {
-    col = TRUE;
+    isColor = TRUE;
     if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class);
-    if (graphic[0].visual == visual_list[i].visual) {
-      def = TRUE;
-    } else {
-      graphic[0].visual = visual_list[i].visual;
-    }
+    isDefault = (graphic[0].visual == visual_list[i].visual);
+    graphic[0].visual = visual_list[i].visual;
     graphic[0].visualclass = FALSE;
     goto test_pixels;
   }
 
+  // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?)
   for (i = 0; (i < Nfound) && (visual_list[i].class != StaticColor); i++);
   if (i != Nfound) {
     if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class);
-    if (graphic[0].visual == visual_list[i].visual) {
-      def = TRUE;
-    } else {
-      graphic[0].visual = visual_list[i].visual;
-    }
+    isDefault = (graphic[0].visual == visual_list[i].visual);
+    graphic[0].visual = visual_list[i].visual;
     graphic[0].visualclass = FALSE;
     goto test_pixels;
   }
 
+  // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?)
   for (i = 0; (i < Nfound) && (visual_list[i].class != StaticGray); i++);
   if (i != Nfound) {
     if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class);
-    if (graphic[0].visual == visual_list[i].visual) {
-      def = TRUE;
-    } else {
-      graphic[0].visual = visual_list[i].visual;
-    }
+    isDefault = (graphic[0].visual == visual_list[i].visual);
+    graphic[0].visual = visual_list[i].visual;
     graphic[0].visualclass = FALSE;
     goto test_pixels;
@@ -136,35 +114,45 @@
   /* NEED TO ADD A COUPLE LINES DEFINING THE VARIOUS HARD COLORS (BLACK, WHITE, AND THE OVERLAYS) */
 
+  // allow user to force a private colormap
   if ((N = get_argument (*argc, argv, "-private"))) {
     remove_argument(N, argc, argv);
-    def = FALSE;
+    isDefault = FALSE;
   } 
 
-  if (!def) {
+  // allocate a private colormap, if needed
+  if (!isDefault) {
     if (DEBUG) fprintf (stderr, "allocated private colormap\n");
     graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
   }
 
-  if (dyn) {
-    /* allocate color cells  */
-    for (graphic[0].Npixels = NPIXELS;
-	 ((graphic[0].Npixels >= 16) && 
-	  !XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels));
-	 graphic[0].Npixels -= 4) {
+  if (isDynamic) {
+    /* allocate color cells */
+    ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_DYNAMIC);
+    ALLOCATE (graphic[0].cmap,   XColor,        NPIXELS_DYNAMIC);
+    for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
       if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels);
+      if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {
+	break;
+      }
     }
 
+    /* insufficient cells, can we make a private colormap? */
+    if (graphic[0].Npixels < 16) {
+      if (!isDefault) {
+	fprintf (stderr, "can't allocate enough cells in private colormap\n");
+	exit (0);
+      }
+      if (DEBUG) fprintf (stderr, "can't allocate enough cells, using private colormap\n");
+      graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
 
-    /* make private colormap  */
-    if (graphic[0].Npixels < 16) {
-      // fprintf (stderr, "can't allocate enough cells, using private colormap\n");
-      graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
-      for (graphic[0].Npixels = NPIXELS;
-	   ((graphic[0].Npixels >= 16) && 
-	    !XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels));
-	   graphic[0].Npixels -= 4);
+      for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
+	if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels);
+	if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {
+	  break;
+	}
+      }
 
       if ((N = get_argument (*argc, argv, "-colorcount"))) {
-	fprintf (stderr, "kii can grab %d colors\n", (int) graphic[0].Npixels);
+	fprintf (stderr, "kapa can grab %d colors\n", graphic[0].Npixels);
 	exit (0);
       } 
@@ -174,15 +162,13 @@
       }
     }
-  }
-
-  if (!dyn) {
-    graphic[0].Npixels = 1024;
-    // fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n");
-    // fprintf (stderr, " this can be avoided by using a dynamic visual class\n");
-    // fprintf (stderr, " (see Kii help page for details)\n");
+  } else {
+    // XXX allocate the unsigned long *pixels here and above
+    ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC);
+    ALLOCATE (graphic[0].cmap,   XColor,        NPIXELS_STATIC);
+    graphic[0].Npixels = NPIXELS_STATIC;
   }
 
   if ((N = get_argument (*argc, argv, "-colorcount"))) {
-    fprintf (stderr, "kii can grab %d colors\n", (int) graphic[0].Npixels);
+    fprintf (stderr, "kii can grab %d colors\n", graphic[0].Npixels);
     exit (0);
   } 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom16.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom16.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom16.c	(revision 15925)
@@ -31,5 +31,5 @@
   dy = image[0].zoom.dy;
 
-  if (image[0].matrix.size == 0) {  /* create a test pattern */
+  if (image[0].image[0].matrix.size == 0) {  /* create a test pattern */
     REALLOCATE (image[0].zoom.data, char, 2*dy*dx);
     bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy);
@@ -48,10 +48,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
@@ -61,6 +61,6 @@
   expand_in  = 1;
 
-  DX = image[0].matrix.Naxis[0];
-  DY = image[0].matrix.Naxis[1];
+  DX = image[0].image[0].matrix.Naxis[0];
+  DY = image[0].image[0].matrix.Naxis[1];
   Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
   Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
@@ -74,5 +74,5 @@
 
   data = out_pix = (unsigned char *) image[0].zoom.data;
-  imdata  = (float *) image[0].matrix.buffer;
+  imdata  = (float *) image[0].image[0].matrix.buffer;
   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom24.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom24.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom24.c	(revision 15925)
@@ -32,5 +32,5 @@
   extra = 4 - (dx * 3) % 4;
 
-  if (image[0].matrix.size == 0) {  /* create a test pattern */
+  if (image[0].image[0].matrix.size == 0) {  /* create a test pattern */
     REALLOCATE (image[0].zoom.data, char, dy*(3*dx+extra));
     bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy);
@@ -52,10 +52,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
@@ -65,6 +65,6 @@
   expand_in  = 1;
 
-  DX = image[0].matrix.Naxis[0];
-  DY = image[0].matrix.Naxis[1];
+  DX = image[0].image[0].matrix.Naxis[0];
+  DY = image[0].image[0].matrix.Naxis[1];
   Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
   Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
@@ -78,5 +78,5 @@
 
   data = out_pix = (unsigned char *) image[0].zoom.data;
-  imdata  = (float *) image[0].matrix.buffer;
+  imdata  = (float *) image[0].image[0].matrix.buffer;
   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom32.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom32.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom32.c	(revision 15925)
@@ -26,5 +26,5 @@
   unsigned long back;
 
-  if (image[0].matrix.size == 0) {  /* create a test pattern */
+  if (image[0].image[0].matrix.size == 0) {  /* create a test pattern */
     REALLOCATE (image[0].zoom.data, char, 4*image[0].zoom.dx*image[0].zoom.dy);
     image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 
@@ -40,10 +40,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
@@ -55,6 +55,6 @@
   dx = image[0].zoom.dx;
   dy = image[0].zoom.dy;
-  DX = image[0].matrix.Naxis[0];
-  DY = image[0].matrix.Naxis[1];
+  DX = image[0].image[0].matrix.Naxis[0];
+  DY = image[0].image[0].matrix.Naxis[1];
   Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
   Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
@@ -68,5 +68,5 @@
 
   out_pix = (unsigned int *) image[0].zoom.data;
-  imdata  = (float *) image[0].matrix.buffer;
+  imdata  = (float *) image[0].image[0].matrix.buffer;
   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom8.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom8.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom8.c	(revision 15925)
@@ -26,5 +26,5 @@
   unsigned long back;
 
-  if (image[0].matrix.size == 0) {  /* create a test pattern */
+  if (image[0].image[0].matrix.size == 0) {  /* create a test pattern */
     REALLOCATE (image[0].zoom.data, char, image[0].zoom.dx*image[0].zoom.dy);
     bzero (image[0].zoom.data, image[0].zoom.dx*image[0].zoom.dy);
@@ -41,10 +41,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
@@ -56,6 +56,6 @@
   dx = image[0].zoom.dx;
   dy = image[0].zoom.dy;
-  DX = image[0].matrix.Naxis[0];
-  DY = image[0].matrix.Naxis[1];
+  DX = image[0].image[0].matrix.Naxis[0];
+  DY = image[0].image[0].matrix.Naxis[1];
   Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
   Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
@@ -69,5 +69,5 @@
 
   out_pix = (unsigned char *) image[0].zoom.data;
-  imdata  = (float *) image[0].matrix.buffer;
+  imdata  = (float *) image[0].image[0].matrix.buffer;
   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/CursorOps.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/CursorOps.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/CursorOps.c	(revision 15925)
@@ -13,6 +13,6 @@
   }
   
-  *x1 = expand*(x2 - image[0].picture.x - 0.5*image[0].picture.dx) + 0.5*image[0].matrix.Naxis[0] - image[0].X;
-  *y1 = expand*(y2 - image[0].picture.y - 0.5*image[0].picture.dy) + 0.5*image[0].matrix.Naxis[1] - image[0].Y;
+  *x1 = expand*(x2 - image[0].picture.x - 0.5*image[0].picture.dx) + 0.5*image[0].image[0].matrix.Naxis[0] - image[0].X;
+  *y1 = expand*(y2 - image[0].picture.y - 0.5*image[0].picture.dy) + 0.5*image[0].image[0].matrix.Naxis[1] - image[0].Y;
   
 }
@@ -31,6 +31,6 @@
   }
   
-  *x1 = (x2 - 0.5*image[0].matrix.Naxis[0] + image[0].X) * expand + image[0].picture.x + 0.5*image[0].picture.dx;
-  *y1 = (y2 - 0.5*image[0].matrix.Naxis[1] + image[0].Y) * expand + image[0].picture.y + 0.5*image[0].picture.dy;
+  *x1 = (x2 - 0.5*image[0].image[0].matrix.Naxis[0] + image[0].X) * expand + image[0].picture.x + 0.5*image[0].picture.dx;
+  *y1 = (y2 - 0.5*image[0].image[0].matrix.Naxis[1] + image[0].Y) * expand + image[0].picture.y + 0.5*image[0].picture.dy;
   
 }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/DragColorbar.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/DragColorbar.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/DragColorbar.c	(revision 15925)
@@ -15,6 +15,6 @@
   Y = mouse_event[0].y;
   Npix = graphic[0].Npixels;
-  slope = image[0].slope;
-  start = image[0].start;
+  slope = image[0].image[0].slope;
+  start = image[0].image[0].start;
   oldfrac_x = oldfrac_y = 10;
   
@@ -63,6 +63,6 @@
       case ButtonPress:
       case ButtonRelease:
-	image[0].start = start;	
-	image[0].slope = slope;
+	image[0].image[0].start = start;	
+	image[0].image[0].slope = slope;
 	return;
 	break;
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Image.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Image.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Image.c	(revision 15925)
@@ -2,6 +2,21 @@
 # include "buttons.h"
 
+int InitImageChannel (KapaImageChannel *channel) {
+
+  /** set up a bunch of default things **/
+  channel->zero = 0;
+  channel->range = 1;
+  channel->start = 0;
+  channel->slope = 1;
+
+  channel->coords.Npolyterms = 0;
+  channel->matrix.size = 0; /* a flag to show there is no data in the matrix */
+  ALLOCATE (channel->matrix.buffer, char, 1);  /* allocate so later free will not crash! */
+
+  return (TRUE);
+}
+
 /* initialization for things not specific to X */
-KapaImageWidget *InitImage () {
+KapaImageWidget *InitImageWidget () {
 
   int i;
@@ -14,14 +29,9 @@
   memset (image, 0, sizeof(KapaImageWidget));
 
-  /** set up a bunch of default things **/
-  image[0].X = image[0].Y = 0;
-  image[0].expand = 1;
-  image[0].zero = 0;
-  image[0].range = 1;
-  image[0].start = 0;
-  image[0].slope = 1;
-  image[0].location = 4;
+  for (i = 0; i < NCHANNELS; i++) {
+    InitImageChannel (&image[0].channel[i]);
+  }
+  image[0].image = &image[0].channel[0];
 
-  image[0].coords.Npolyterms = 0;
   for (i = 0; i < NOVERLAYS; i++) {
     image[0].overlay[i].Nobjects = 0;
@@ -30,9 +40,12 @@
     image[0].overlay[i].color = graphic[0].overlay_color[i];
   }
-  image[0].matrix.size = 0; /* a flag to show there is no data in the matrix */
+
+  image[0].X = 0.0;
+  image[0].Y = 0.0;
+  image[0].expand = 1;
+  image[0].location = 4;
 
   image[0].MovePointer = TRUE;
   image[0].DecimalDegrees  = TRUE;
-  ALLOCATE (image[0].matrix.buffer, char, 1);  /* allocate so later free will not crash! */
   ALLOCATE (image[0].picture.data, char, 1);   /* allocate so later free will not crash! */
   ALLOCATE (image[0].cmapbar.data, char, 1);   /* allocate so later free will not crash! */
@@ -48,6 +61,6 @@
   InitButtonFunc (&image[0].rainbow_button, rainbow);
 
-  InitButtonSize (&image[0].puns_button, puns_width, puns_height, puns_bits);
-  InitButtonFunc (&image[0].puns_button, puns);
+  InitButtonSize (&image[0].heat_button, heat_width, heat_height, heat_bits);
+  InitButtonFunc (&image[0].heat_button, heat);
 
   InitButtonSize (&image[0].recenter_button, recenter_width, recenter_height, recenter_bits);
@@ -131,5 +144,5 @@
     DrawButton (graphic, &image[0].grey_button);
     DrawButton (graphic, &image[0].rainbow_button);
-    DrawButton (graphic, &image[0].puns_button);
+    DrawButton (graphic, &image[0].heat_button);
     DrawButton (graphic, &image[0].hms_button);
 
@@ -152,5 +165,5 @@
     free (image[0].overlay[i].objects);
   }
-  free (image[0].matrix.buffer);
+  free (image[0].image[0].matrix.buffer);
   free (image[0].picture.data);
   free (image[0].cmapbar.data);
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretKeys.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretKeys.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretKeys.c	(revision 15925)
@@ -61,8 +61,8 @@
       if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor;
       Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);
-      XY_to_RD (&R, &D, X, Y, &image[0].coords);
+      XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords);
 
-      DX = image[0].matrix.Naxis[0];
-      DY = image[0].matrix.Naxis[1];
+      DX = image[0].image[0].matrix.Naxis[0];
+      DY = image[0].image[0].matrix.Naxis[1];
 
       if (X < 0) goto off_image;
@@ -70,5 +70,5 @@
       if (X >= DX) goto off_image;
       if (Y >= DY) goto off_image;
-      imdata = (float *) image[0].matrix.buffer;
+      imdata = (float *) image[0].image[0].matrix.buffer;
       Z      = imdata[DX*(int)(Y) + (int)(X)];
     }
@@ -89,4 +89,19 @@
   switch (keysym) {
 
+    case XK_F1:
+      image[0].image = &image[0].channel[0];
+      Reorient (graphic, image, image[0].X, image[0].Y, 0);
+      break;
+
+    case XK_F2:
+      image[0].image = &image[0].channel[1];
+      Reorient (graphic, image, image[0].X, image[0].Y, 0);
+      break;
+
+    case XK_F3:
+      image[0].image = &image[0].channel[2];
+      Reorient (graphic, image, image[0].X, image[0].Y, 0);
+      break;
+
     case XK_KP_Home:
     case XK_Home:
@@ -103,6 +118,6 @@
     case XK_Return:
       Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);
-      X = 0.5*image[0].matrix.Naxis[0] - X;
-      Y = 0.5*image[0].matrix.Naxis[1] - Y;
+      X = 0.5*image[0].image[0].matrix.Naxis[0] - X;
+      Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y;
       Reorient (graphic, image, X, Y, 0);
       break;
@@ -133,9 +148,9 @@
 
     case XK_KP_Add:
-      image[0].zero += 0.1*image[0].range;
+      image[0].image[0].zero += 0.1*image[0].image[0].range;
       Reorient (graphic, image, image[0].X, image[0].Y, 0);
       break;
     case XK_KP_Subtract:
-      image[0].zero -= 0.1*image[0].range;
+      image[0].image[0].zero -= 0.1*image[0].image[0].range;
       Reorient (graphic, image, image[0].X, image[0].Y, 0);
       break;
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretPresses.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretPresses.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretPresses.c	(revision 15925)
@@ -36,8 +36,8 @@
       Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);
 
-      XY_to_RD (&R, &D, X, Y, &image[0].coords);
+      XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords);
 
-      DX = image[0].matrix.Naxis[0];
-      DY = image[0].matrix.Naxis[1];
+      DX = image[0].image[0].matrix.Naxis[0];
+      DY = image[0].image[0].matrix.Naxis[1];
 
       if (X < 0) goto off_image;
@@ -45,5 +45,5 @@
       if (X >= DX) goto off_image;
       if (Y >= DY) goto off_image;
-      imdata = (float *) image[0].matrix.buffer;
+      imdata = (float *) image[0].image[0].matrix.buffer;
       Z      = imdata[DX*(int)(Y) + (int)(X)];
     }
@@ -102,6 +102,6 @@
 
   Screen_to_Image (&X, &Y, (double)mouse_event[0].x, (double)mouse_event[0].y, image);
-  X = 0.5*image[0].matrix.Naxis[0] - X;
-  Y = 0.5*image[0].matrix.Naxis[1] - Y;
+  X = 0.5*image[0].image[0].matrix.Naxis[0] - X;
+  Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y;
 
   switch (mouse_event[0].button) {
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/JPEGit24.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/JPEGit24.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/JPEGit24.c	(revision 15925)
@@ -84,10 +84,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
@@ -108,6 +108,6 @@
   dx = image[0].picture.dx;
   dy = image[0].picture.dy;
-  DX = image[0].matrix.Naxis[0];
-  DY = image[0].matrix.Naxis[1];
+  DX = image[0].image[0].matrix.Naxis[0];
+  DY = image[0].image[0].matrix.Naxis[1];
 
   /* X,Y are the image coordinates of the first image pixel */
@@ -145,5 +145,5 @@
   ALLOCATE (line_buffer, JSAMPLE, 3*dx);
 
-  imdata = (float *) image[0].matrix.buffer;
+  imdata = (float *) image[0].image[0].matrix.buffer;
   in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadOverlay.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadOverlay.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadOverlay.c	(revision 15925)
@@ -14,5 +14,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadPicture.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadPicture.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadPicture.c	(revision 15925)
@@ -13,5 +13,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
@@ -24,19 +24,19 @@
   KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]);
   KiiScanMessage (sock, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale);
-  KiiScanMessage (sock, "%lf %lf %s %s",  &image[0].zero, &image[0].range, image[0].name, image[0].file);
-  KiiScanMessage (sock, "%lf %lf %d", &image[0].min,  &image[0].max, &header.size);
-  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval1, &image[0].coords.crpix1, &image[0].coords.cdelt1, &image[0].coords.pc1_1, &image[0].coords.pc1_2);
-  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].coords.crval2, &image[0].coords.crpix2, &image[0].coords.cdelt2, &image[0].coords.pc2_1, &image[0].coords.pc2_2);
-  KiiScanMessage (sock, "%s", image[0].coords.ctype);
+  KiiScanMessage (sock, "%lf %lf %s %s",  &image[0].image[0].zero, &image[0].image[0].range, image[0].image[0].name, image[0].image[0].file);
+  KiiScanMessage (sock, "%lf %lf %d", &image[0].image[0].min,  &image[0].image[0].max, &header.size);
+  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval1, &image[0].image[0].coords.crpix1, &image[0].image[0].coords.cdelt1, &image[0].image[0].coords.pc1_1, &image[0].image[0].coords.pc1_2);
+  KiiScanMessage (sock, "%lf %f %f %f %f", &image[0].image[0].coords.crval2, &image[0].image[0].coords.crpix2, &image[0].image[0].coords.cdelt2, &image[0].image[0].coords.pc2_1, &image[0].image[0].coords.pc2_2);
+  KiiScanMessage (sock, "%s", image[0].image[0].coords.ctype);
 
-  gfits_free_matrix (&image[0].matrix);
-  gfits_create_matrix (&header, &image[0].matrix);
+  gfits_free_matrix (&image[0].image[0].matrix);
+  gfits_create_matrix (&header, &image[0].image[0].matrix);
 
   fcntl (sock, F_SETFL, O_NONBLOCK);  
 
   status = 1;
-  buff = image[0].matrix.buffer;
+  buff = image[0].image[0].matrix.buffer;
   bytes_left = header.size;
-  image[0].matrix.size = 0;
+  image[0].image[0].matrix.size = 0;
   while (bytes_left > 0) {
     status = read (sock, buff, bytes_left);
@@ -46,5 +46,5 @@
     }
     if (status != -1) { /* pipe has data */
-      image[0].matrix.size += status;
+      image[0].image[0].matrix.size += status;
       bytes_left -= status;
       buff = (char *)(buff + status);
@@ -54,8 +54,8 @@
   fcntl (sock, F_SETFL, !O_NONBLOCK);  
 
-  if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].matrix.size);
+  if (DEBUG) fprintf (stderr, "read %d bytes\n", image[0].image[0].matrix.size);
   /* it it not obvious this condition should kill kii, but ... */
-  if (image[0].matrix.size != header.size) {  
-    fprintf (stderr, "error: expected %d bytes, but got only %d\n", header.size, image[0].matrix.size);
+  if (image[0].image[0].matrix.size != header.size) {  
+    fprintf (stderr, "error: expected %d bytes, but got only %d\n", header.size, image[0].image[0].matrix.size);
     return (FALSE);
   }
@@ -63,5 +63,5 @@
   if (!USE_XWINDOW) return (TRUE);
 
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   if (DEBUG) fprintf (stderr, "remapped image\n");
   Refresh ();
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadTickmarks.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadTickmarks.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadTickmarks.c	(revision 15925)
@@ -11,5 +11,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/MakeColormap.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/MakeColormap.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/MakeColormap.c	(revision 15925)
@@ -1,4 +1,3 @@
 # include "Ximage.h"
-# define NPIXELS 64
 
 static char default_cmap[] = "grayscale";
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/PSPixmap.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/PSPixmap.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/PSPixmap.c	(revision 15925)
@@ -13,6 +13,6 @@
   /* start at the last line, print lines in decending order */
   buff = (unsigned char *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1);
-  slope = image[0].slope;
-  start = image[0].start;
+  slope = image[0].image[0].slope;
+  start = image[0].image[0].start;
   back  = graphic[0].back;
 
@@ -46,6 +46,6 @@
   /* start at the last line, print lines in decending order */
   buff = (unsigned short *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1);
-  slope = image[0].slope;
-  start = image[0].start;
+  slope = image[0].image[0].slope;
+  start = image[0].image[0].start;
   back  = graphic[0].back;
 
@@ -83,6 +83,6 @@
   /* start at the last line, print lines in decending order */
   buff = (unsigned char *)&image[0].picture.data[(dy - 1)*(3*dx + extra)];
-  slope = image[0].slope;
-  start = image[0].start;
+  slope = image[0].image[0].slope;
+  start = image[0].image[0].start;
   back  = graphic[0].back;
 
@@ -123,6 +123,6 @@
   /* start at the last line, print lines in decending order */
   buff = (unsigned int *)image[0].picture.data + image[0].picture.dx*(image[0].picture.dy - 1);
-  slope = image[0].slope;
-  start = image[0].start;
+  slope = image[0].image[0].slope;
+  start = image[0].image[0].start;
   back  = graphic[0].back;
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap.c	(revision 15925)
@@ -1,18 +1,18 @@
 # include "Ximage.h"
 
-void Remap (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
+void Remap (Graphic *graphic, KapaImageWidget *image) {
 
   switch (graphic[0].Nbits) {
   case 8:
-    Remap8 (graphic, image, matrix);
+    Remap8  (graphic, image, &image->image->matrix);
     break;
   case 16:
-    Remap16 (graphic, image, matrix);
+    Remap16 (graphic, image, &image->image->matrix);
     break;
   case 24:
-    Remap24 (graphic, image, matrix);
+    Remap24 (graphic, image, &image->image->matrix);
     break;
   case 32:
-    Remap32 (graphic, image, matrix);
+    Remap32 (graphic, image, &image->image->matrix);
     break;
   }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap16.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap16.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap16.c	(revision 15925)
@@ -38,10 +38,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap24.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap24.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap24.c	(revision 15925)
@@ -40,10 +40,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c	(revision 15925)
@@ -39,10 +39,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap8.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap8.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap8.c	(revision 15925)
@@ -33,10 +33,10 @@
   // define the color transform parameters
   MaxValue = graphic[0].Npixels - 1;
-  if (image[0].range != 0.0) {
-    slope = graphic[0].Npixels / image[0].range;
-    start = graphic[0].Npixels * image[0].zero / image[0].range;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
   } else {
     slope = 1.0;
-    start = image[0].zero;
+    start = image[0].image[0].zero;
   }
 
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Reorient.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Reorient.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Reorient.c	(revision 15925)
@@ -38,5 +38,5 @@
   }
 
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
   Refresh ();
  
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/Rescale.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/Rescale.c	(revision 15925)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/Rescale.c	(revision 15925)
@@ -0,0 +1,41 @@
+# include "Ximage.h"
+
+void Rescale (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
+
+  int i, j, DX, DY, value;
+  float *iData;
+  unsigned short *oData;
+  float slope;
+  float start;
+  unsigned short MaxValue;
+
+  // define the color transform parameters
+  MaxValue = graphic[0].Npixels - 1;
+  if (image[0].image[0].range != 0.0) {
+    slope = graphic[0].Npixels / image[0].image[0].range;
+    start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
+  } else {
+    slope = 1.0;
+    start = image[0].image[0].zero;
+  }
+
+  DX = matrix[0].Naxis[0];
+  DY = matrix[0].Naxis[1];
+
+  oData = graphic[0].pixmap;
+  iData = (float *) matrix[0].buffer;
+
+  // convert pixel data values to pixel index values (0 - Npixel)
+  for (i = 0; i < DX; i++) {
+    for (j = 0; j < DY; j++, iData++, oData++) {
+      value = slope * iData - start;
+      if (value < 0) value = 0;
+      if (value > MaxValue) value = MaxValue;
+      *oData = value;
+    }
+  }
+}
+
+/** in order to call this function, graphic[0].pixmap must be allocated to match the
+ * current matrix (current channel) 
+ */
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c	(revision 15925)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c	(revision 15925)
@@ -0,0 +1,34 @@
+# include "Ximage.h"
+
+int SetChannel (int sock) {
+  
+  int Nchannel;
+  Graphic *graphic;
+  Section *section;
+  KapaImageWidget *image;
+
+  graphic = GetGraphic ();
+  section = GetActiveSection();
+  if (section->image == NULL) {
+    section->image = InitImageWidget ();
+    SetSectionSizes (section);
+  }
+  image = section->image;
+
+  KiiScanMessage (sock, "%d", &Nchannel);
+
+  if (Nchannel <  0) return (TRUE);
+  if (Nchannel >= NCHANNELS) return (TRUE);
+  
+  image[0].image = &image[0].channel[Nchannel];
+
+  if (!USE_XWINDOW) return (TRUE);
+
+  Remap (graphic, image);
+  if (DEBUG) fprintf (stderr, "remapped image\n");
+  Refresh ();
+  if (DEBUG) fprintf (stderr, "refreshed\n");
+  XFlush (graphic[0].display);
+
+  return (TRUE);
+}
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c	(revision 15925)
@@ -1,26 +1,31 @@
 # include "Ximage.h"
 
-/*** this function uses only private colormaps.  it should try the standard colormap
-     first to get better control over the smooth greyscales ***/
-
-/** red,green,blue are values in range 0x0000 to 0xffff **/
+# define SETVALUE(VAR,VALUE,MINVAL,MAXVAL) { \
+  float tmp = (VALUE); \
+  if (tmp < MINVAL) { \
+    VAR = MINVAL; \
+  } else if (tmp > MAXVAL) { \
+    VAR = MAXVAL; \
+  } else { \
+    VAR = tmp; \
+  } }   
 
 int SetColormap (char *name) {
 
-  int i;
-  float scale;
+  int i, ref1, ref2;
+  float scale, blueRef, redRef, greenRef;
   Graphic *graphic;
 
   graphic = GetGraphic();
 
+  // red,green,blue are values in range 0x0000 to 0xffff
+  scale = 0xffff / (graphic[0].Npixels - 1);
+
   /* greyscale */
-  if ((!strcmp (name, "grayscale")) || (!strcmp (name, "greyscale"))) {
-
-    scale = 0xffff / graphic[0].Npixels;
-
+  if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) {
     for (i = 0; i < graphic[0].Npixels; i++) {  
-      graphic[0].cmap[i].red   = 0xffff - i*scale;
-      graphic[0].cmap[i].green = 0xffff - i*scale;
-      graphic[0].cmap[i].blue  = 0xffff - i*scale;
+      SETVALUE (graphic[0].cmap[i].red,   0xffff - i*scale, 0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].green, 0xffff - i*scale, 0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].blue,  0xffff - i*scale, 0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
@@ -28,9 +33,9 @@
   }
   /* -grayscale */
-  if ((!strcmp (name, "-grayscale")) || (!strcmp (name, "-greyscale"))) {
+  if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) {
     for (i = 0; i < graphic[0].Npixels; i++) {  
-      graphic[0].cmap[i].red = 256*(255*i/graphic[0].Npixels);
-      graphic[0].cmap[i].green = 256*(255*i/graphic[0].Npixels);
-      graphic[0].cmap[i].blue = 256*(255*i/graphic[0].Npixels);
+      SETVALUE (graphic[0].cmap[i].red,   i*scale, 0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].green, i*scale, 0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].blue,  i*scale, 0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
@@ -38,27 +43,29 @@
   }
   /* heat */
-  if (!strcmp (name, "Puns")) {
+  if (!strcasecmp (name, "Heat")) {
+    greenRef = 0.25*graphic[0].Npixels*scale*2.0;
+    blueRef  = 0.50*graphic[0].Npixels*scale*2.0;
     for (i = 0; i < (int)(0.25*graphic[0].Npixels); i++) {  
+      SETVALUE (graphic[0].cmap[i].red,   2*i*scale, 0, 0xffff);
       graphic[0].cmap[i].green = 0;
-      graphic[0].cmap[i].blue = 0;
-      graphic[0].cmap[i].red = MIN (256*255, 256*255*2*i/(1.0*graphic[0].Npixels));  
+      graphic[0].cmap[i].blue  = 0;
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
-    for (i = (int)(0.25*graphic[0].Npixels); i < (int)(0.50*graphic[0].Npixels); i++) {  
-      graphic[0].cmap[i].red = MIN (256*255, 256*255*2*i/(1.0*graphic[0].Npixels));
-      graphic[0].cmap[i].green = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.25));
+    for (i = 0.25*graphic[0].Npixels; i < 0.50*graphic[0].Npixels; i++) {  
+      SETVALUE (graphic[0].cmap[i].red,   2*i*scale,            0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].green, 2*i*scale - greenRef, 0, 0xffff);
       graphic[0].cmap[i].blue = 0;
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
     for (i = (int)(0.50*graphic[0].Npixels); i < (int)(0.75*graphic[0].Npixels); i++) {  
-      graphic[0].cmap[i].red = 256*255;
-      graphic[0].cmap[i].green = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.25));
-      graphic[0].cmap[i].blue = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.50));
+      graphic[0].cmap[i].red = 0xffff;
+      SETVALUE (graphic[0].cmap[i].green, 2*i*scale - greenRef, 0, 0xffff);
+      SETVALUE (graphic[0].cmap[i].blue,  2*i*scale - blueRef,  0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
     for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) {  
-      graphic[0].cmap[i].red = 256*255;
-      graphic[0].cmap[i].green = 256*255;
-      graphic[0].cmap[i].blue = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.50));
+      graphic[0].cmap[i].red   = 0xffff;
+      graphic[0].cmap[i].green = 0xffff;
+      SETVALUE (graphic[0].cmap[i].blue,  2*i*scale - blueRef,  0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
@@ -66,27 +73,31 @@
   }
   /* rainbow */
-  if (!strcmp (name, "Rainbow")) {
+  if (!strcasecmp (name, "Rainbow")) {
+    redRef   = 0.25*graphic[0].Npixels*scale*4.0;
+    greenRef = 0.50*graphic[0].Npixels*scale*4.0;
+    blueRef  = 0.50*graphic[0].Npixels*scale*4.0;
     for (i = 0; i < (int)(0.25*graphic[0].Npixels); i++) {  
-      graphic[0].cmap[i].red = 0;
+      graphic[0].cmap[i].red   = 0;
       graphic[0].cmap[i].green = 0;
-      graphic[0].cmap[i].blue = 256*(255*4*(i/(1.0*graphic[0].Npixels)));  
+      SETVALUE (graphic[0].cmap[i].blue,  4*i*scale,           0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
     for (i = (int)(0.25*graphic[0].Npixels); i < (int)(0.50*graphic[0].Npixels); i++) {  
-      graphic[0].cmap[i].red = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.25));
+      SETVALUE (graphic[0].cmap[i].red,   4*i*scale - redRef,  0, 0xffff);
       graphic[0].cmap[i].green = 0;
-      graphic[0].cmap[i].blue = 256*(255*4*(0.50 - (i/(1.0*graphic[0].Npixels))));
+      SETVALUE (graphic[0].cmap[i].blue,  blueRef - 4*i*scale, 0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
     for (i = (int)(0.50*graphic[0].Npixels); i < (int)(0.75*graphic[0].Npixels); i++) {  
-      graphic[0].cmap[i].red = 256*255;
-      graphic[0].cmap[i].green = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.50));
+      graphic[0].cmap[i].red  = 0xffff;
+      SETVALUE (graphic[0].cmap[i].green,  4*i*scale - greenRef, 0, 0xffff);
       graphic[0].cmap[i].blue = 0;
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
+    blueRef  = 0.75*graphic[0].Npixels*scale*4.0;
     for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels; i++) {  
-      graphic[0].cmap[i].red = 256*255;
-      graphic[0].cmap[i].green = 256*255;
-      graphic[0].cmap[i].blue = 256*(255*4*((i/(1.0*graphic[0].Npixels)) - 0.75));
+      graphic[0].cmap[i].red   = 0xffff;
+      graphic[0].cmap[i].green = 0xffff;
+      SETVALUE (graphic[0].cmap[i].blue,  4*i*scale - blueRef, 0, 0xffff);
       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageData.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageData.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageData.c	(revision 15925)
@@ -11,5 +11,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
@@ -18,8 +18,8 @@
   // get image data from client 
   KiiScanMessage (sock, "%lf %lf %s", 
-		  &image[0].zero, 
-		  &image[0].range, 
-		  image[0].name, 
-		  image[0].file);
+		  &image[0].image[0].zero, 
+		  &image[0].image[0].range, 
+		  image[0].image[0].name, 
+		  image[0].image[0].file);
 
   // XXX when we go to 32bit, this should remap the image
@@ -37,5 +37,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
@@ -43,8 +43,8 @@
 
   KiiSendMessage (sock, "%g %g %s %s", 
-		  image[0].zero,
-		  image[0].range,
-		  image[0].name,
-		  image[0].file);
+		  image[0].image[0].zero,
+		  image[0].image[0].range,
+		  image[0].image[0].name,
+		  image[0].image[0].file);
 
   return (TRUE);
@@ -61,5 +61,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
@@ -67,16 +67,16 @@
   
   KiiScanMessage (sock, "%f %f %f %f", 
-		  &image[0].coords.pc1_1, &image[0].coords.pc2_2,
-		  &image[0].coords.pc1_2, &image[0].coords.pc2_1);
+		  &image[0].image[0].coords.pc1_1, &image[0].image[0].coords.pc2_2,
+		  &image[0].image[0].coords.pc1_2, &image[0].image[0].coords.pc2_1);
 
-  KiiScanMessage (sock, "%s", image[0].coords.ctype);
+  KiiScanMessage (sock, "%s", image[0].image[0].coords.ctype);
 
   KiiScanMessage (sock, "%lf %lf %f %f %f %f", 
-		  &image[0].coords.crval1,
-		  &image[0].coords.crval2,
-		  &image[0].coords.crpix1,
-		  &image[0].coords.crpix2,
-		  &image[0].coords.cdelt1,
-		  &image[0].coords.cdelt2);
+		  &image[0].image[0].coords.crval1,
+		  &image[0].image[0].coords.crval2,
+		  &image[0].image[0].coords.crpix1,
+		  &image[0].image[0].coords.crpix2,
+		  &image[0].image[0].coords.cdelt1,
+		  &image[0].image[0].coords.cdelt2);
 
   return (TRUE);  
@@ -90,5 +90,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
@@ -96,16 +96,16 @@
 
   KiiSendMessage (sock, "%g %g %g %g", 
-		  image[0].coords.pc1_1, image[0].coords.pc2_2,
-		  image[0].coords.pc1_2, image[0].coords.pc2_1);
+		  image[0].image[0].coords.pc1_1, image[0].image[0].coords.pc2_2,
+		  image[0].image[0].coords.pc1_2, image[0].image[0].coords.pc2_1);
 
-  KiiSendMessage (sock, "%s", image[0].coords.ctype);
+  KiiSendMessage (sock, "%s", image[0].image[0].coords.ctype);
 
   KiiSendMessage (sock, "%g %g %g %g %g %g", 
-		  image[0].coords.crval1,
-		  image[0].coords.crval2,
-		  image[0].coords.crpix1,
-		  image[0].coords.crpix2,
-		  image[0].coords.cdelt1,
-		  image[0].coords.cdelt2);
+		  image[0].image[0].coords.crval1,
+		  image[0].image[0].coords.crval2,
+		  image[0].image[0].coords.crpix1,
+		  image[0].image[0].coords.crpix2,
+		  image[0].image[0].coords.cdelt1,
+		  image[0].image[0].coords.cdelt2);
 
   return (TRUE);
@@ -120,5 +120,5 @@
   section = GetActiveSection();
   if (section->image == NULL) {
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
     SetSectionSizes (section);
   }
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageSize.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageSize.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetImageSize.c	(revision 15925)
@@ -40,5 +40,5 @@
       }
       if (USE_XWINDOW) CreatePicture (image, graphic);
-      Remap (graphic, image, &image[0].matrix);
+      Remap (graphic, image);
       return;
 
@@ -104,8 +104,8 @@
       image[0].rainbow_button.y = image[0].PS_button.y;
 
-      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
-      image[0].puns_button.y = image[0].PS_button.y;
-
-      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
+      image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
+      image[0].heat_button.y = image[0].PS_button.y;
+
+      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
       image[0].recenter_button.y = image[0].PS_button.y;
       break;
@@ -172,8 +172,8 @@
       image[0].rainbow_button.y = image[0].PS_button.y;
 
-      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
-      image[0].puns_button.y = image[0].PS_button.y;
-
-      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
+      image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
+      image[0].heat_button.y = image[0].PS_button.y;
+
+      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
       image[0].recenter_button.y = image[0].PS_button.y;
       break;
@@ -238,8 +238,8 @@
       image[0].rainbow_button.y = image[0].PS_button.y;
 
-      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
-      image[0].puns_button.y = image[0].PS_button.y;
-
-      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
+      image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
+      image[0].heat_button.y = image[0].PS_button.y;
+
+      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
       image[0].recenter_button.y = image[0].PS_button.y;
       break;
@@ -304,8 +304,8 @@
       image[0].rainbow_button.y = image[0].PS_button.y;
 
-      image[0].puns_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
-      image[0].puns_button.y = image[0].PS_button.y;
-
-      image[0].recenter_button.x = image[0].puns_button.x + image[0].puns_button.dx + PAD1;
+      image[0].heat_button.x = image[0].rainbow_button.x + image[0].rainbow_button.dx + PAD1;
+      image[0].heat_button.y = image[0].PS_button.y;
+
+      image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1;
       image[0].recenter_button.y = image[0].PS_button.y;
       break;
@@ -321,5 +321,5 @@
     CreateZoom (image, graphic, 0, 0); 
   }
-  Remap (graphic, image, &image[0].matrix);
+  Remap (graphic, image);
 
   return;
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetToolbox.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetToolbox.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/SetToolbox.c	(revision 15925)
@@ -17,5 +17,5 @@
   section = GetActiveSection();
   if (section->image == NULL) { 
-    section->image = InitImage ();
+    section->image = InitImageWidget ();
   }
   section->image->location = location;
@@ -24,5 +24,5 @@
   if (!USE_XWINDOW) return;
 
-  Remap (graphic, section->image, &section->image->matrix);
+  Remap (graphic, section->image);
   if (DEBUG) fprintf (stderr, "remapped image\n");
   Refresh ();
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/StatusBox.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/StatusBox.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/StatusBox.c	(revision 15925)
@@ -6,6 +6,6 @@
 
   if (image[0].MovePointer) {
-    x = 0.5*image[0].matrix.Naxis[0];
-    y = 0.5*image[0].matrix.Naxis[1];
+    x = 0.5*image[0].image[0].matrix.Naxis[0];
+    y = 0.5*image[0].image[0].matrix.Naxis[1];
     z = -1;
     image[0].x = x;
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdatePointer.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdatePointer.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdatePointer.c	(revision 15925)
@@ -19,13 +19,13 @@
   if (image[0].MovePointer && InPicture ((XButtonEvent *)event, &image[0].picture)) {
 
-    data = (float *) image[0].matrix.buffer;
+    data = (float *) image[0].image[0].matrix.buffer;
     Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, image);
 
     z = -1;
     if (x < 0) goto skip;
-    if (x >= image[0].matrix.Naxis[0]) goto skip;
+    if (x >= image[0].image[0].matrix.Naxis[0]) goto skip;
     if (y < 0) goto skip;
-    if (y >= image[0].matrix.Naxis[1]) goto skip;
-    z = data[(int)(y)*image[0].matrix.Naxis[0] + (int)(x)];
+    if (y >= image[0].image[0].matrix.Naxis[1]) goto skip;
+    z = data[(int)(y)*image[0].image[0].matrix.Naxis[0] + (int)(x)];
 
   skip:
@@ -47,5 +47,5 @@
   
   if (InPicture ((XButtonEvent *)event, &image[0].cmapbar)) {
-    z = image[0].zero  + image[0].range * (event[0].x - image[0].cmapbar.x) / image[0].cmapbar.dx;
+    z = image[0].image[0].zero  + image[0].image[0].range * (event[0].x - image[0].cmapbar.x) / image[0].cmapbar.dx;
     textpad = graphic[0].font[0].ascent;
     XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
Index: /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdateStatusBox.c
===================================================================
--- /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdateStatusBox.c	(revision 15924)
+++ /branches/eam_branch_20071222/Ohana/src/kapa2/src/UpdateStatusBox.c	(revision 15925)
@@ -7,5 +7,5 @@
   char line[100];
 
-  XY_to_RD (&ra, &dec, x, y, &image[0].coords);
+  XY_to_RD (&ra, &dec, x, y, &image[0].image[0].coords);
 
   textpad = graphic[0].font[0].ascent;
@@ -26,10 +26,10 @@
     
     bzero (line, 100);
-    sprintf (line, "%-25s", image[0].file); 
+    sprintf (line, "%-25s", image[0].image[0].file); 
     XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
 		 image[0].text_x + PAD1, image[0].text_y + 5*textpad + 5*PAD1, line, strlen(line));
     
     bzero (line, 100);
-    sprintf (line, "(%s)                                          ", image[0].name); 
+    sprintf (line, "(%s)                                          ", image[0].image[0].name); 
     XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
 		 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
