IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 25, 2015, 8:08:57 PM (11 years ago)
Author:
eugene
Message:

adding compression of images in prep for compression / uncompression of tables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/extern/gzip.c

    r23816 r38322  
    151151    return err;
    152152}
     153
     154int gfits_compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
     155{
     156  z_stream stream;
     157  int err;
     158
     159  stream.next_in = (Bytef*)source;
     160  stream.avail_in = (uInt)sourceLen;
     161
     162  /* Check for source > 64K on 16-bit machine: */
     163  if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
     164
     165  stream.next_out = dest;
     166  stream.avail_out = (uInt)*destLen; // allocated space
     167  if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
     168
     169  stream.zalloc = (alloc_func)0;
     170  stream.zfree = (free_func)0;
     171
     172  err = deflateInit(&stream);
     173  if (err != Z_OK) return err;
     174
     175  // XXX this is written to do the compression in a single pass.  it could be re-done to have
     176  // the compression occur in a series of steps
     177  err = deflate(&stream, Z_FINISH);
     178  if (err != Z_STREAM_END) {
     179    deflateEnd(&stream);
     180    return err;
     181  }
     182  assert (stream.total_out <= *destLen);
     183  *destLen = stream.total_out;
     184 
     185  err = deflateEnd(&stream);
     186  return err;
     187}
Note: See TracChangeset for help on using the changeset viewer.