Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/prototypes.h	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/include/prototypes.h	(revision 29783)
@@ -46,4 +46,5 @@
 /* EventLoop */
 int           PScommand           PROTO((int sock));
+int           PNGcommand          PROTO((int sock));
 int           CheckPipe           PROTO((void));
 int           Reconfig            PROTO((XEvent *event));
@@ -52,5 +53,5 @@
 
 /* CheckPipe */
-int           PNGit               PROTO((int sock));
+int           PNGit               PROTO((char *filename));
 int           PPMit               PROTO((int sock));
 int           LoadFrame           PROTO((int sock));
@@ -212,4 +213,6 @@
 int	      Overlay3		  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      PSfunction	  PROTO((Graphic *graphic, KapaImageWidget *image));
+int	      PNGfunction	  PROTO((Graphic *graphic, KapaImageWidget *image));
+int	      JPEGfunction	  PROTO((Graphic *graphic, KapaImageWidget *image));
 
 /* misc functions */
@@ -219,5 +222,6 @@
 int  	      SaveOverlay  (int sock);
 int  	      CSaveOverlay (int sock);
-int  	      JPEGit24     (int sock);
+int  	      JPEGit24     (char *filename);
+int  	      JPEGcommand  (int sock);
 
 int  	      UpdatePointer (Graphic *graphic, XMotionEvent *event);
Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/ButtonFunctions.c
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 29783)
@@ -7,4 +7,20 @@
 
   status = PSit ("kapa.ps", "default", TRUE, KAPA_PS_NEWPLOT);
+  return (status);
+}
+
+int PNGfunction (Graphic *graphic, KapaImageWidget *image) {
+
+  int status;
+
+  status = PNGit ("kapa.png");
+  return (status);
+}
+
+int JPEGfunction (Graphic *graphic, KapaImageWidget *image) {
+
+  int status;
+
+  status = JPEGit24 ("kapa.jpg");
   return (status);
 }
Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/CheckPipe.c
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/CheckPipe.c	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/CheckPipe.c	(revision 29783)
@@ -89,9 +89,15 @@
   
   if (!strcmp (word, "PNGF")) {
-    status = PNGit (sock);
-    KiiSendCommand (sock, 4, "DONE");
-    FINISHED (status);
-  }
-  
+    status = PNGcommand (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (status);
+  }
+  
+  if (!strcmp (word, "JPEG")) {
+    status = JPEGcommand (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (status);
+  }
+
   if (!strcmp (word, "PPMF")) {
     status = PPMit (sock);
@@ -304,10 +310,4 @@
   }
 
-  if (!strcmp (word, "JPEG")) {
-    status = JPEGit24 (sock);
-    KiiSendCommand (sock, 4, "DONE");
-    FINISHED (status);
-  }
-
   if (!strcmp (word, "CENT")) {
     status = Center (sock);
Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/Image.c
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/Image.c	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/Image.c	(revision 29783)
@@ -88,5 +88,8 @@
 
   InitButtonSize (&image[0].PS_button, PS_width, PS_height, PS_bits);
-  InitButtonFunc (&image[0].PS_button, PSfunction);
+  // InitButtonFunc (&image[0].PS_button, PSfunction);
+  image->PS_button.function_1 = PSfunction;
+  image->PS_button.function_2 = PNGfunction;
+  image->PS_button.function_3 = JPEGfunction;
 
   InitButtonSize (&image[0].grey_button, grey_width, grey_height, grey_bits);
Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/JPEGit24.c
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/JPEGit24.c	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/JPEGit24.c	(revision 29783)
@@ -8,6 +8,16 @@
 # define WHITE_B 255
 
+int JPEGcommand (int sock) {
+
+  int status;
+  char filename[1024];
+
+  KiiScanMessage (sock, "%s", filename);
+  status = JPEGit24 (filename);
+  return (status);
+}
+
 // XXX this currently writes out the jpeg for just the active image
-int JPEGit24 (int sock) {
+int JPEGit24 (char *filename) {
 
   struct jpeg_compress_struct cinfo;
@@ -31,9 +41,5 @@
   unsigned short *in_pix, *in_pix_ref;
   unsigned char *pixel1, *pixel2, *pixel3;
-  char filename[1024];
   FILE *f;
-
-  /* expect a line telling the number of bytes and a filename */
-  KiiScanMessage (sock, "%s", filename);
 
   graphic = GetGraphic();
@@ -199,5 +205,5 @@
     bDrawSetBuffer (buffer);
     for (i = 0; i < NOVERLAYS; i++) {
-      if (image[i].overlay[i].active) bDrawOverlay (image, i);
+      if (image[0].overlay[i].active) bDrawOverlay (image, i);
     }
 
Index: /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PNGit.c
===================================================================
--- /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PNGit.c	(revision 29782)
+++ /branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/PNGit.c	(revision 29783)
@@ -10,5 +10,15 @@
 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic);
 
-int PNGit (int sock) {
+int PNGcommand (int sock) {
+
+  int status;
+  char filename[1024];
+
+  KiiScanMessage (sock, "%s", filename);
+  status = PNGit (filename);
+  return (status);
+}
+
+int PNGit (char *filename) {
 
   FILE *f;
@@ -16,5 +26,4 @@
   png_infop info_ptr;
   int status, Npalette;
-  char filename[1024];
   bDrawBuffer *buffer = NULL;
   Graphic *graphic = NULL;
@@ -22,7 +31,4 @@
 
   graphic = GetGraphic();
-
-  /* expect a line telling the number of bytes and a filename */
-  KiiScanMessage (sock, "%s", filename);
 
   f = fopen (filename, "w");
