home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Library / include / pnghuffe.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-17  |  1.9 KB  |  73 lines

  1. #ifndef __PNGHUFFE_H
  2. #define __PNGHUFFE_H
  3. //
  4. // Copyright (c) 1997,1998 Colosseum Builders, Inc.
  5. // All rights reserved.
  6. //
  7. // Colosseum Builders, Inc. makes no warranty, expressed or implied
  8. // with regards to this software. It is provided as is.
  9. //
  10. // See the README.TXT file that came with this software for restrictions
  11. // on the use and redistribution of this file or send E-mail to
  12. // info@colosseumbuilders.com
  13. //
  14.  
  15. //
  16. //  Title:  PNG Huffman Encoding Class
  17. //
  18. //  Author:  John M. Miano  miano@colosseumbuilders.com
  19. //
  20. //  Description:
  21. //
  22. //    This class implements the Huffman encoder for the PNG encoder.
  23. //
  24.  
  25. #include "png.h"
  26.  
  27. class PngEncoder ;
  28.  
  29. class PngHuffmanEncoder
  30. {
  31. public:
  32.   PngHuffmanEncoder () ;
  33.   virtual ~PngHuffmanEncoder () ;
  34.  
  35.   // ENCODING FUNCTIONS
  36.  
  37.   // This function resets the table so that the object can be used
  38.   // over again.
  39.   void Reset () ;
  40.  
  41.   // This function increases the frequency for a huffman value.
  42.   void IncrementFrequency (unsigned int value) ;
  43.  
  44.   // This function creates the Huffman codes from the code frequencies.
  45.   void BuildTable (unsigned int maxlength) ;
  46.  
  47.   // This function returns the Huffman code and code length to encode the
  48.   // specified value.
  49.   void Encode (unsigned int value, UBYTE2 &code, UBYTE1 &size) const ;
  50.  
  51. private:
  52.   PngHuffmanEncoder (const PngHuffmanEncoder &) ;
  53.   PngHuffmanEncoder &operator=(const PngHuffmanEncoder &) ;
  54.  
  55.   // This function builds the structures needed for Huffman
  56.   // decoding after the table data has been read.
  57.   void MakeTable () ;
  58.  
  59.   // frequencies [n] is the number of times the value "n" needs to
  60.   // be encoded.
  61.   unsigned int *frequencies ;
  62.  
  63.   // Values used to encode values.
  64.   //   ehufsi [n] is the number of bits required to code "n"
  65.   //   ehufco [n] is the Huffman code for "n"
  66.   UBYTE1 *ehufsi ;
  67.   UBYTE2 *ehufco ;
  68.  
  69.   friend class PngEncoder ;
  70. } ;
  71.  
  72. #endif
  73.