# include "Ximage.h"
# define SCAN \
  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 */ \
  (DEBUG) && fprintf (stderr, "buffer: <%s>\n", buffer); \


int Resize (Graphic *graphic, Layout *layout) {
 
  int status, Nbytes;
  unsigned int NX, NY;
  char buffer[128];

  SCAN;
  sscanf (buffer, "%d %d", &NX, &NY);

  NX += ZOOM_X + 3*PAD1 + 25;
  NY += 2*PAD1 + PAD2 + COLORPAD + 25;

  if ((graphic[0].dx == NX) && (graphic[0].dy == NY)) 
    return (TRUE);

  /*  graphic[0].dx = MAX(NX,  MIN_WIDTH); 
  graphic[0].dy = MAX(NY, MIN_HEIGHT); */
  graphic[0].dx = MAX(NX, 50); 
  graphic[0].dy = MAX(NY, 50); 

  XResizeWindow (graphic[0].display, graphic[0].window, NX, NY);

  PositionPictures (layout, graphic);
  CreateColorbar (layout, graphic);
  CreatePicture (layout, graphic);
  Remap (graphic, layout, &layout[0].matrix); 

  XClearWindow (graphic[0].display, graphic[0].window);
  Refresh (graphic, layout, 1);

  return (TRUE);
}
