home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / jpeg.h < prev    next >
C/C++ Source or Header  |  2000-05-12  |  2KB  |  58 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : jpeg.h                                                                 //
  10. //  Description: KPicture class, wrapper for JPEG encoding/decoding                  //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. class KPicture
  15. {
  16.     void Release(void);
  17.     int     Allocate(int width, int height, int channels, bool bBits=true);
  18.  
  19. public:
  20.     BITMAPINFO * m_pBMI;
  21.     BYTE       * m_pBits;
  22.  
  23.     BYTE       * m_pJPEG;
  24.     int             m_nJPEGSize;
  25.  
  26.     KPicture()
  27.     {
  28.         m_pBMI  = NULL;
  29.         m_pBits = NULL;
  30.  
  31.         m_pJPEG     = NULL;
  32.         m_nJPEGSize = 0;
  33.     }
  34.  
  35.     ~KPicture()
  36.     {
  37.         Release();
  38.  
  39.         if ( m_pJPEG )
  40.             delete [] m_pJPEG;
  41.     }
  42.  
  43.     int GetWidth(void) const
  44.     {
  45.         return m_pBMI->bmiHeader.biWidth;
  46.     }
  47.  
  48.     int GetHeight(void) const
  49.     {
  50.         return m_pBMI->bmiHeader.biHeight;
  51.     }
  52.  
  53.     BOOL DecodeJPEG(const void * jpegimage, int jpegsize);
  54.     BOOL QueryJPEG(const void * jpegimage, int jpegsize);
  55.  
  56.     BOOL LoadJPEGFile(const TCHAR * filename);
  57.     BOOL SaveJPEGFile(const TCHAR * fileName, int quality);
  58. };