IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2009, 12:45:31 PM (17 years ago)
Author:
eugene
Message:

handle images compressed with CFITSIO gzip compression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/matrix/F_uncompress_data.c

    r18272 r23724  
    2222int pl_l2pi (short *ll_src, int xs, int *px_dst, int npix);
    2323
     24/* functions defined in gzip.c */
     25int gfits_gz_stripheader (unsigned char *data, int *ndata);
     26int gfits_uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
     27
    2428int gfits_uncompress_data (char *zdata, int Nzdata, char *cmptype, char **optname, char **optvalue, int Nopt, char *outdata, int *Nout, int out_pixsize) {
    2529
     
    3034  if (!strcasecmp(cmptype, "GZIP_1")) {
    3135    unsigned long tNout = *Nout * out_pixsize;
     36
     37    // for GZIP data, I need to check for and remove the header on the first block:
     38    gfits_gz_stripheader ((unsigned char *)zdata, &Nzdata);
     39
    3240    // uncompress does not require us to know the expected number of pixel; it tells us the number
    33     status = uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata);
     41    status = gfits_uncompress ((Bytef *) outdata, &tNout, (Bytef *) zdata, Nzdata);
    3442    if (status != Z_OK) {
    3543      fprintf (stderr, "error in uncompress (GZIP)\n");
    3644      return (FALSE);
    3745    }
    38     *Nout = tNout;
     46
     47    // the resulting uncompressed data is byteswapped
     48    if (!gfits_byteswap_zdata (outdata, tNout, out_pixsize)) return (FALSE);
     49
     50    *Nout = tNout / out_pixsize;
    3951    return (TRUE);
    4052  }
Note: See TracChangeset for help on using the changeset viewer.