Index: /trunk/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /trunk/Ohana/src/kapa2/include/prototypes.h	(revision 14499)
+++ /trunk/Ohana/src/kapa2/include/prototypes.h	(revision 14500)
@@ -67,4 +67,7 @@
 int           SetImageData        PROTO((int sock));
 int           GetImageData        PROTO((int sock));
+int           SetImageCoords      PROTO((int sock));
+int           GetImageCoords      PROTO((int sock));
+int           GetImageRange       PROTO((int sock));
 
 int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
Index: /trunk/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/CheckPipe.c	(revision 14499)
+++ /trunk/Ohana/src/kapa2/src/CheckPipe.c	(revision 14500)
@@ -155,4 +155,22 @@
   }
   
+  if (!strcmp (word, "SIMC")) {
+    SetImageCoords (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+  
+  if (!strcmp (word, "GIMC")) {
+    GetImageCoords (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+  
+  if (!strcmp (word, "GIMR")) {
+    GetImageRange (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+  
   if (!strcmp (word, "GIMD")) {
     GetImageData (sock);
Index: /trunk/Ohana/src/kapa2/src/SetImageData.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/SetImageData.c	(revision 14499)
+++ /trunk/Ohana/src/kapa2/src/SetImageData.c	(revision 14500)
@@ -52,2 +52,87 @@
   return (TRUE);
 }
+
+int SetImageCoords (int sock) {
+  
+  int i;
+  double xmin, xmax, ymin, ymax;
+  Graphic *graphic;
+  Section *section;
+  KapaImageWidget *image;
+
+  graphic = GetGraphic();
+
+  section = GetActiveSection();
+  if (section->image == NULL) {
+    section->image = InitImage ();
+    SetSectionSizes (section);
+  }
+  image = section->image;
+  
+  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);
+
+  KiiScanMessage (sock, "%s", 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);
+
+  return (TRUE);  
+}
+
+int GetImageCoords (int sock) {
+  
+  Section *section;
+  KapaImageWidget *image;
+
+  section = GetActiveSection();
+  if (section->image == NULL) {
+    section->image = InitImage ();
+    SetSectionSizes (section);
+  }
+  image = section->image;
+
+  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);
+
+  KiiSendMessage (sock, "%s", 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);
+
+  return (TRUE);
+}
+
+int GetImageRange (int sock) {
+  
+  Section *section;
+  KapaImageWidget *image;
+  double Xmin, Xmax, Ymin, Ymax;
+
+  section = GetActiveSection();
+  if (section->image == NULL) {
+    section->image = InitImage ();
+    SetSectionSizes (section);
+  }
+  image = section->image;
+
+  Screen_to_Image (&Xmin, &Ymin, 0.0, 0.0, image);
+  Screen_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, image);
+
+  KiiSendMessage (sock, "%g %g %g %g", Xmin, Xmax, Ymin, Ymax);
+
+  return (TRUE);
+}
+
Index: /trunk/Ohana/src/kapa2/src/SetImageSize.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/SetImageSize.c	(revision 14499)
+++ /trunk/Ohana/src/kapa2/src/SetImageSize.c	(revision 14500)
@@ -77,4 +77,5 @@
       image[0].text_dx = ZOOM_X;
       image[0].text_dy = 6*textpad + 7*PAD1;
+      image[0].text_dyo = 3*textpad + 4*PAD1;
 
       image[0].overlay_button[0].x = image[0].text_x;
@@ -144,4 +145,5 @@
       image[0].text_dx = ZOOM_X;
       image[0].text_dy = 6*textpad + 7*PAD1;
+      image[0].text_dyo = 3*textpad + 4*PAD1;
 
       image[0].overlay_button[0].x = image[0].text_x;
@@ -209,4 +211,5 @@
       image[0].text_dx = ZOOM_X;
       image[0].text_dy = 6*textpad + 7*PAD1;
+      image[0].text_dyo = 3*textpad + 4*PAD1;
 
       image[0].overlay_button[0].x = image[0].text_x;
@@ -274,4 +277,5 @@
       image[0].text_dx = ZOOM_X;
       image[0].text_dy = 6*textpad + 7*PAD1;
+      image[0].text_dyo = 3*textpad + 4*PAD1;
 
       image[0].overlay_button[0].x = image[0].text_x;
Index: /trunk/Ohana/src/libkapa/include/kapa.h
===================================================================
--- /trunk/Ohana/src/libkapa/include/kapa.h	(revision 14499)
+++ /trunk/Ohana/src/libkapa/include/kapa.h	(revision 14500)
@@ -124,4 +124,8 @@
 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
+
+int KapaSetImageCoords (int fd, Coords *coords);
+int KapaGetImageCoords (int fd, Coords *coords);
+int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax);
 
 /* KiiOverlay.c */
Index: /trunk/Ohana/src/libkapa/src/KiiPicture.c
===================================================================
--- /trunk/Ohana/src/libkapa/src/KiiPicture.c	(revision 14499)
+++ /trunk/Ohana/src/libkapa/src/KiiPicture.c	(revision 14500)
@@ -155,4 +155,67 @@
 }
 
+int KapaSetImageCoords (int fd, Coords *coords) {
+
+  /* tell kapa to look for the incoming image */
+  KiiSendCommand (fd, 4, "SIMC"); 
+  
+  KiiSendMessage (fd, "%g %g %g %g", 
+		  coords[0].pc1_1, coords[0].pc2_2,
+		  coords[0].pc1_2, coords[0].pc2_1);
+
+  KiiSendMessage (fd, "%s", coords[0].ctype);
+
+  KiiSendMessage (fd, "%g %g %g %g %g %g", 
+		  coords[0].crval1,
+		  coords[0].crval2,
+		  coords[0].crpix1,
+		  coords[0].crpix2,
+		  coords[0].cdelt1,
+		  coords[0].cdelt2);
+
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaGetImageCoords (int fd, Coords *coords) {
+
+  /* tell kapa to look for the incoming image */
+  KiiSendCommand (fd, 4, "GIMC"); 
+  
+  KiiScanMessage (fd, "%f %f %f %f", 
+		  &coords[0].pc1_1, &coords[0].pc2_2,
+		  &coords[0].pc1_2, &coords[0].pc2_1);
+
+  KiiScanMessage (fd, "%s", coords[0].ctype);
+
+  KiiScanMessage (fd, "%lf %lf %f %f %f %f", 
+		  &coords[0].crval1,
+		  &coords[0].crval2,
+		  &coords[0].crpix1,
+		  &coords[0].crpix2,
+		  &coords[0].cdelt1,
+		  &coords[0].cdelt2);
+
+  // XXX at some point, we need to add polynomials and 2-level mosaic
+  // astrometry here.
+
+  coords[0].Npolyterms = 0;
+
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax) {
+
+  /* tell kapa to look for the incoming image */
+  KiiSendCommand (fd, 4, "GIMR"); 
+  
+  KiiScanMessage (fd, "%lf %lf %lf %lf", Xmin, Xmax, Ymin, Ymax);
+
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+
 /* this function should be broken into pieces: 
    KiiSendImage
