# include "Ximage.h"

int 
TestPicture (graphic, layout)
     Graphic graphic[];
     Layout  layout[];
{

  Header header;
  char buffer[1024], *buff;
  int status, bytes_left, Nbytes, i, j;
  double frac;

  fits_free_matrix (&layout[0].matrix);

  header.Naxes = 2;
  header.Naxis[0] = 512;
  header.Naxis[1] = 512;
  header.bitpix = 8;
  header.unsign = 0;
  header.bzero = 0;
  header.bscale = 1;

  layout[0].zero = 0;
  layout[0].range = layout[0].Npixels;
  layout[0].min = 0; 
  layout[0].max = layout[0].Npixels;
  
  fits_create_matrix (&header, &layout[0].matrix);

  frac = layout[0].Npixels / (512.0*512.0);
  buff = layout[0].matrix.buffer;
  for (i = 0; i < 512; i++) {
    for (j = 0; j < 512; j++, buff++) {
      *buff = (int)(i*j*frac);
    }
  }

/*
  Remap (layout, &layout[0].matrix);
  layout[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 
					layout[0].picture.data, 
					layout[0].picture.dx, layout[0].picture.dy, 8, 0);

  (DEBUG) && fprintf (stderr, "remapped image\n", layout[0].matrix.size);
  Refresh (graphic, layout);
  
  (DEBUG) && fprintf (stderr, "refreshed\n", layout[0].matrix.size);
  XFlush (graphic[0].display);
*/
}


/*
   layout[0].X = 0;
   layout[0].Y = 0;
   layout[0].expand = 1;
*/
  
