# include "Ximage.h"

/*************/
int 
SaveOverlay (graphic, layout)
     Graphic graphic[];
     Layout  layout[];
{

  char buffer[256], filename[256];
  int i, status, Nbytes, N;
  FILE *f;

  status = read (layout[0].Ximage, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%*s %d", &Nbytes); 
  status = read (layout[0].Ximage, buffer, Nbytes); 
  buffer[Nbytes] = 0; 
  sscanf (buffer, "%*s %d %s", &N, filename);
  
  f = fopen (filename, "w");
  if (f == NULL) {
    fprintf (stderr, "could not open %s\n", filename);
    return (TRUE);
  }

  for (i = 0; i < layout[0].overlay[N].Nobjects; i++) {
    fprintf (f, "%s %lf %lf %lf %lf\n", 
	     layout[0].overlay[N].objects[i].type,
	     layout[0].overlay[N].objects[i].x,
	     layout[0].overlay[N].objects[i].y,
	     layout[0].overlay[N].objects[i].dx,
	     layout[0].overlay[N].objects[i].dy);
  }
  fclose (f);
  return (TRUE);
}


/* this routine is independent of the number of overlays */

