compress - Image Compression/Decompression Coders

- NAME
- SYNOPSIS
- FUNCTION DESCRIPTIONS
  - ASCII85Encode
  - HuffmanDecodeImage
  - HuffmanEncodeImage
  - Huffman2DEncodeImage
  - LZWEncodeImage
  - PackbitsEncodeImage
  - RunlengthDecodeImage
  - RunlengthEncodeImage
  - SetRunlengthEncoder
  - SetRunlengthPackets
  - ZLIBEncodeImage

# NAME

compress - Image Compression/Decompression Coders

# SYNOPSIS

unsigned int Huffman2DEncodeImage( ImageInfo *image_info, Image `*image` );

unsigned int HuffmanDecodeImage( Image `*image` );

unsigned int HuffmanEncodeImage( const ImageInfo *image_info, Image `*image` );

unsigned int LZWEncodeImage( Image *image, const unsigned int number_pixels, unsigned char `*pixels` );

unsigned int PackbitsEncodeImage( Image *image, const unsigned int number_pixels, unsigned char `*pixels` );

unsigned int RunlengthDecodeImage( Image `*image` );

unsigned int RunlengthEncodeImage( Image `*image` );

SetRunlengthEncoder( packet );

SetRunlengthPackets( image, packets );

unsigned int ZLIBEncodeImage( Image *image, const unsigned long number_pixels, const unsigned int quality, unsigned char `*pixels` );

# FUNCTION DESCRIPTIONS

## ASCII85Encode

Method ASCII85Encode encodes data in ASCII base-85 format. ASCII base-85 encoding produces five ASCII printing characters from every four bytes of binary data.

The format of the ASCII85Encode method is:

        void Ascii85Initialize(void)

A description of each parameter follows:

code:

  a binary unsigned char to encode to ASCII 85.

file:

  write the encoded ASCII character to this file.

## HuffmanDecodeImage

Method HuffmanDecodeImage uncompresses an image via Huffman-coding.

The format of the HuffmanDecodeImage method is:

> unsigned int HuffmanDecodeImage ( Image *image );

A description of each parameter follows:

status:

  Method HuffmanDecodeImage returns True if all the pixels are compressed without error, otherwise False.

image:

  The address of a structure of type Image.

## HuffmanEncodeImage

Method HuffmanEncodeImage compresses an image via Huffman-coding.

The format of the HuffmanEncodeImage method is:

> unsigned int HuffmanEncodeImage ( const ImageInfo *image_info, Image *image );

A description of each parameter follows:

status:

  Method HuffmanEncodeImage returns True if all the pixels are compressed without error, otherwise False.

image_info:

  Specifies a pointer to an ImageInfo structure.

image:

  The address of a structure of type Image.

## Huffman2DEncodeImage

Method Huffman2DEncodeImage compresses an image via two-dimensional Huffman-coding.

The format of the Huffman2DEncodeImage method is:

> unsigned int Huffman2DEncodeImage ( ImageInfo *image_info, Image *image );

A description of each parameter follows:

status:

  Method Huffman2DEncodeImage returns True if all the pixels are compressed without error, otherwise False.

image_info:

  Specifies a pointer to an ImageInfo structure.

image:

  The address of a structure of type Image.

## LZWEncodeImage

Method LZWEncodeImage compresses an image via LZW-coding specific to Postscript Level II or Portable Document Format. To ensure portability, the binary LZW bytes are encoded as ASCII base-85.

The format of the LZWEncodeImage method is:

> unsigned int LZWEncodeImage ( Image *image, const unsigned int number_pixels, unsigned char *pixels );

A description of each parameter follows:

status:

  Method LZWEncodeImage returns True if all the pixels are compressed without error, otherwise False.

image:

  The address of a structure of type Image.

number_pixels:

  An unsigned interger that specifies the number of pixels to compress.

pixels:

  The address of an unsigned array of characters containing the pixels to compress.

## PackbitsEncodeImage

Method PackbitsEncodeImage compresses an image via Macintosh Packbits encoding specific to Postscript Level II or Portable Document Format. To ensure portability, the binary Packbits bytes are encoded as ASCII Base-85.

The format of the PackbitsEncodeImage method is:

> unsigned int PackbitsEncodeImage ( Image *image, const unsigned int number_pixels, unsigned char *pixels );

A description of each parameter follows:

status:

  Method PackbitsEncodeImage returns True if all the pixels are compressed without error, otherwise False.

image:

  The address of a structure of type Image.

number_pixels:

  An unsigned integer that specifies the number of pixels to compress.

pixels:

  The address of an unsigned array of characters containing the pixels to compress.

## RunlengthDecodeImage

Method RunlengthDecodeImage unpacks the packed image pixels into runlength-encoded pixel packets. The packed image pixel memory is then freed.

The format of the RunlengthDecodeImage method is:

> unsigned int RunlengthDecodeImage ( Image *image );

A description of each parameter follows:

status:

  Method RunlengthDecodeImage return True if the image is decoded. False is returned if there is an error occurs.

image:

  The address of a structure of type Image.

## RunlengthEncodeImage

Method RunlengthEncodeImage packs the runlength-encoded pixel packets into the minimum number of bytes.

The format of the RunlengthEncodeImage method is:

> unsigned int RunlengthEncodeImage ( Image *image );

A description of each parameter follows:

status:

  Method RunlengthEncodeImage return the number of bytes the image consumes. Zero is returned if an error occurs.

image:

  The address of a structure of type Image.

## SetRunlengthEncoder

Method SetRunlengthEncoder initializes the runlength encoder.

The format of the SetRunlengthEncoder function is:

> SetRunlengthEncoder ( packet );

A description of each parameter follows:

packet:

  Specifies a RunlengthPacket type.

## SetRunlengthPackets

Method SetRunlengthPackets initializes the runlength encoder.

The format of the SetRunlengthPackets function is:

> SetRunlengthPackets ( image, packets );

A description of each parameter follows:

image:

  The address of a structure of type Image.

packets:

  The number of runlength packets.

## ZLIBEncodeImage

Method ZLIBEncodeImage compresses an image via ZLIB-coding specific to Postscript Level II or Portable Document Format. To ensure portability, the binary ZLIB bytes are encoded as ASCII base-85.

The format of the ZLIBEncodeImage method is:

> unsigned int ZLIBEncodeImage ( Image *image, const unsigned long number_pixels, const unsigned int quality, unsigned char *pixels );

A description of each parameter follows:

status:

  Method ZLIBEncodeImage returns True if all the pixels are compressed without error, otherwise False.

file:

  The address of a structure of type FILE. ZLIB encoded pixels are written to this file.

number_pixels:

  An unsigned integer that specifies the number of pixels to compress.

quality:

  the compression level (0-100).

pixels:

  The address of an unsigned array of characters containing the pixels to compress.