home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c07 / inc / jpdequan.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-25  |  1.9 KB  |  74 lines

  1. #ifndef __JPDEQUAN_H
  2. #define __JPDEQUAN_H
  3. #include <iostream>
  4. #include "jpeg.h"
  5. #include "bitimage.h"
  6.  
  7. class JpegDecoder ;
  8.  
  9. class JpegDecoderQuantizationTable
  10. {
  11. public:
  12.   JpegDecoderQuantizationTable() ;
  13.   ~JpegDecoderQuantizationTable() {}
  14.  
  15.   // This function tells the caller if the quantization table has been
  16.   // defined by the JPEG input stream.
  17.   bool Defined () const ;
  18.  
  19.   // Function to read the quantization table from the input stream.
  20.   void ReadTable (JpegDecoder &decoder, unsigned int precision) ;
  21.  
  22.   // This function builds the scaled quantization tables used in
  23.   // fast IDCT implementations.
  24.   void BuildScaledTables () ;
  25.  
  26.   // This function prints the contents of the quantization table to
  27.   // an output stream.
  28.   void Print (std::ostream &) const ;
  29.  
  30.   UBYTE2 operator[](unsigned int) const ;
  31.   UBYTE2 &operator[](unsigned int) ;
  32. private:
  33.   // Dummy Declarations for Required Member Functions
  34.   JpegDecoderQuantizationTable (const JpegDecoderQuantizationTable&) ;
  35.   JpegDecoderQuantizationTable &operator=(const JpegDecoderQuantizationTable&) ;
  36.  
  37.   // Quantization Values in Zig-Zag Order.
  38.   UBYTE2 data_values [JpegSampleSize] ;
  39.  
  40.  
  41.   // This flag gets set to true when the quantization is defined in the
  42.   // JPEG input stream. It is used to ensure that an compressed scan does
  43.   // not attempt to use an undefined quantization table.
  44.   bool table_defined ;
  45.  
  46.   friend class JpegDecoderDataUnit ;
  47. } ;
  48.  
  49. inline bool JpegDecoderQuantizationTable::Defined () const
  50. {
  51.   return table_defined ;
  52. }
  53.  
  54.  
  55. inline std::ostream &operator<<(std::ostream &strm,
  56.                                 const JpegDecoderQuantizationTable &du)
  57. {
  58.   du.Print (strm) ;
  59.   return strm ;
  60. }
  61.  
  62. inline UBYTE2 &JpegDecoderQuantizationTable::operator[](unsigned int index)
  63. {
  64.   return data_values [index] ;
  65. }
  66.  
  67. inline UBYTE2 JpegDecoderQuantizationTable::operator[](unsigned int index) const
  68. {
  69.   return data_values [index] ;
  70. }
  71.  
  72.  
  73. #endif
  74.