home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c06 / src / jpegdeco.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-20  |  470 b   |  28 lines

  1. #include "jpegdeco.h"
  2.  
  3. using namespace std ;
  4.  
  5. JpegDecoder::JpegDecoder (istream &strm)
  6. {
  7.   input_stream = &strm ;
  8.   bit_position = 0 ;
  9.   return ;
  10. }
  11. UBYTE1 JpegDecoder::ReadByte ()
  12. {
  13.   UBYTE1 data ;
  14.   input_stream->read ((char *) &data, 1) ;
  15.   return data ;
  16. }
  17. int JpegDecoder::NextBit ()
  18. {
  19.   if (bit_position == 0)
  20.   {
  21.     bit_buffer = ReadByte () ;
  22.     bit_position = 8 ;
  23.   }
  24.   -- bit_position ;
  25.   return (bit_buffer >> bit_position) & 1 ;
  26. }
  27.  
  28.