# include "Ximage.h"

int Center (Graphic *graphic, Layout *layout) {

  char buffer[1024];
  int status, zoom, Nbytes;
  double X, Y;

  status = read (layout[0].Ximage, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%*s %d", &Nbytes); 
  status = read (layout[0].Ximage, buffer, Nbytes); 
  buffer[status] = 0; /* make the string easy to parse */ 
  sscanf (buffer, "%lf %lf %d", &X,  &Y, &zoom);

  layout[0].X = 0.5*layout[0].matrix.Naxis[0] - X;
  layout[0].Y = 0.5*layout[0].matrix.Naxis[1] - Y;
  if ((zoom != 0) && (zoom != -1)) {
    layout[0].expand = zoom;
  }

  Remap (graphic, layout, &layout[0].matrix);
  Refresh (graphic, layout, 0);

  XFlush (graphic[0].display);
  return (TRUE);
}

