# include <ohana.h>
# include <gfitsio.h>

int gfits_data_size (Header *header) {
  
  int i, Nrec, size;

  if (header[0].Naxes == 0) return (0);

  size = abs(header[0].bitpix / 8);

  for (i = 0; i < header[0].Naxes; i++)
    size *= header[0].Naxis[i];

  // XXX do I multiply this times gcount?
  size += header[0].pcount;

  /* round up to next complete block */
  if (size % FT_RECORD_SIZE) {
    Nrec = 1 + (int) (size / FT_RECORD_SIZE);
    size = FT_RECORD_SIZE * Nrec;
  }

  return (size);
}

int gfits_data_min_size (Header *header) {
  
  int i, size;

  if (header[0].Naxes == 0) return (0);

  size = abs(header[0].bitpix / 8);

  for (i = 0; i < header[0].Naxes; i++)
    size *= header[0].Naxis[i];

  // XXX do I multiply this times gcount?
  size += header[0].pcount;

  return (size);
}
