class Compress { protected: public: enum CompressType { NO_COMPRESS, // no compression UNIX_COMPRESS, // Compressed FITS file (UNIX) H_COMPRESS, // Hcompressed FITS file ULDA_COMPRESS, // ULDA compressed FITS file GZIP_COMPRESS // GZIPed FITS file }; Compress(); int compress(int read_fd, int write_fd, CompressType type, int compress_flag = 1); int decompress(int read_fd, int write_fd, CompressType type); int compress(const char* infile, const char* outfile, CompressType type, int compress_flag = 1, int mmap_flag = 1); int decompress(const char* infile, const char* outfile, CompressType type, int mmap_flag = 1); int compress(const char* file, CompressType type, int compress_flag = 1, int mmap_flag = 1); int decompress(const char* file, CompressType type, int mmap_flag = 1); int compress(const char* inbuf, int inbufsz, char*& outbuf, int& outbufsz, CompressType ctype, int compress_flag = 1); int decompress(const char* inbuf, int inbufsz, char*& outbuf, int& outbufsz, CompressType ctype); };
This class is a C++ wrapper around the CADC "press" routines for FITS image compression. The methods all do the same thing: compress or decompress an image. Some methods take file names as arguments, others pointers to memory areas. The type of compression is specified as an enum value "CompressType". The methods called "compress" all take an optional flag argument that indicates compression or decompression. The methods called "decompress" are shortcut, inline methods that call compress with the decompress flag on.
compress(read_fd, write_fd, type, compress_flag) Compress (or decompress), reading from the given read file descriptor and writing the results to the given write fd. If compress_flag is true, compress, otherwise decompress the file. decompress(read_fd, write_fd, type) Decompress, reading from the given read file descriptor and writing the results to the given write fd. compress(infile, outfile, type, compress_flag, mmap_flag) Compress (or decompress) the given input file and put the result in outfile. If compress_flag is true, compress, otherwise decompress the file. If mmap_flag is true, use mmap to map the file to memory. Note: we can just open the file and use the fd, but the "press" C routines do unbuffered I/O on each char, which is slow. We can mmap the file to memory and use the "mem to mem" version to improve speed somewhat. decompress(infile, outfile, type, mmap_flag) Decompress the given input file and put the result in outfile. compress(file, type, compress_flag, mmap_flag) Compress (decompress) the file in place using the given compress type. If compress_flag is true, compress, otherwise decompress the file. decompress(file, type, mmap_flag) Decompress the file in place. compress(inbuf, inbufsz, outbuf, outbufsz, ctype, compress_flag) Compress (or decompress) the contents of inbuf using the given compress type and allocate the results to outbuf. inbufsz is the size of the input buffer. outbufsz is an estimate of the outbuf size on input and the actual size on output. If compress_flag is true, compress, otherwise decompress the file. It is the caller's responsibility to free() the outbuf when no longer needed. decompress(inbuf, inbufsz, outbuf, outbufsz, ctype) Decompress inbuf and allocate results in outbuf.
- - - - - - Last change: 07 May 99
Please send questions or comments to abrighto@eso.org.
Copyright © 1998 ESO - European Southern Observatory