Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

plpicdec.h

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plpicdec.h,v 1.1 2004/05/21 21:02:53 maxx Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLPICDEC
00012 #define INCL_PLPICDEC
00013 
00014 #ifndef INCL_PLBITMAP
00015 #include "plbitmap.h"
00016 #endif
00017 
00018 #ifndef INCL_PLDATASRC
00019 #include "pldatasrc.h"
00020 #endif
00021 
00026 class PLPicDecoder : public PLObject
00027 {
00028 
00029 
00030 public:
00033   PLPicDecoder
00034     ();
00035 
00037   virtual ~PLPicDecoder
00038     ();
00039 
00046   virtual void MakeBmpFromFile
00047     ( const char * pszFName,
00048       PLBmp * pBmp,
00049       int BPPWanted = 0,
00050       PLIProgressNotification * pProgNot = NULL
00051     );
00052 
00053 #ifdef _WINDOWS
00067   virtual void MakeBmpFromResource
00068     ( HINSTANCE hInstResource, int ResourceID,
00069       PLBmp * pBmp,
00070       int BPPWanted = 0,
00071       const char* ResType = NULL,
00072       HMODULE hResModule = 0
00073           );
00074 #endif
00075 
00083   virtual void PLPicDecoder::MakeBmpFromMemory
00084     ( unsigned char * ucMemSrc,
00085       int MemSrcSize,
00086       PLBmp * pBmp,
00087       int BPPWanted = 0,
00088       PLIProgressNotification * pProgNot = NULL
00089     );
00090 
00096   virtual void MakeBmp
00097     ( PLDataSource * pDataSrc,
00098       PLBmp * pBmp,
00099       int BPPWanted = 0
00100     );
00101 
00102   void OpenFile
00103     ( const char * pszFName, 
00104       PLIProgressNotification * pProgNot = NULL
00105     );
00106 
00107   virtual void Close
00108     ();
00109 
00123   static void SetTraceConfig
00124     ( int Level,
00125       char * pszFName
00126     );
00127 
00128   // This function is needed by callbacks outside of any object,
00129   // so it's public and static. It should not be called from
00130   // outside of the library.
00131   static void raiseError
00132     ( int Code,
00133       char * pszErr
00134     );
00135 
00137   static void Trace
00138     ( int TraceLevel,
00139       const char * pszMessage
00140     );
00141 
00142 protected:
00150   virtual void DoDecode
00151     ( PLBmp * pBmp,
00152       PLDataSource * pDataSrc
00153     );
00154 
00155   PLBYTE * unpackPictRow
00156     ( PLBYTE * pLineBuf,
00157       PLDataSource * pDataSrc,
00158       int Width,
00159       int rowBytes,
00160       int SrcBytes
00161     );
00162 
00163   PLBYTE ReadByte
00164     ( PLDataSource * pDataSrc
00165     );
00166 
00167   // Machine-independent routines for byte-order conversion.
00168 
00169   PLWORD ReadIWord
00170     ( PLDataSource * pDataSrc
00171     );
00172 
00173   PLWORD ReadMWord
00174     ( PLDataSource * pDataSrc
00175     );
00176 
00177   PLLONG ReadILong
00178     ( PLDataSource * pDataSrc
00179     );
00180 
00181   PLLONG ReadMLong
00182     ( PLDataSource * pDataSrc
00183     );
00184 
00185   PLDataSource * m_pDataSrc;
00186 
00187 private:
00189   // Member variables.
00190 
00191   static int    m_TraceLevel;    // 0: Trace only errors.
00192                                  // 1: Trace top-level calls.
00193                                  // 2: Trace picture format info.
00194                                  // 3: Trace misc. info.
00195   static char * m_pszTraceFName; // Name of trace file. NULL if trace to
00196                                  // MSVC debug console.
00197 };
00198 
00199 
00200 inline PLBYTE PLPicDecoder::ReadByte
00201     ( PLDataSource * pDataSrc
00202     )
00203 {
00204 
00205   return *(pDataSrc->ReadNBytes (1));
00206 }
00207 
00208 
00209 inline PLWORD PLPicDecoder::ReadIWord
00210     ( PLDataSource * pDataSrc
00211     )
00212 {
00213   PLBYTE * pData = pDataSrc->Read2Bytes ();
00214   // This should work regardless of the destination byte order ;-)
00215   return pData[0] + (pData[1]<<8);
00216 }
00217 
00218 
00219 inline PLWORD PLPicDecoder::ReadMWord
00220     ( PLDataSource * pDataSrc
00221     )
00222 {
00223   PLBYTE * pData = pDataSrc->Read2Bytes ();
00224   return pData[1] + (pData[0]<<8);
00225 }
00226 
00227 
00228 inline PLLONG PLPicDecoder::ReadILong
00229     ( PLDataSource * pDataSrc
00230     )
00231 {
00232   PLBYTE * pData = pDataSrc->Read4Bytes ();
00233   return pData[0] + (pData[1]<<8) + (pData[2]<<16) + (pData[3]<<24);
00234 }
00235 
00236 inline PLLONG PLPicDecoder::ReadMLong
00237     ( PLDataSource * pDataSrc
00238     )
00239 {
00240   PLBYTE * pData = pDataSrc->Read4Bytes ();
00241   return pData[3] + (pData[2]<<8) + (pData[1]<<16) + (pData[0]<<24);
00242 }
00243 
00244 #endif
00245 /*
00246 /--------------------------------------------------------------------
00247 |
00248 |      $Log: plpicdec.h,v $
00249 |      Revision 1.1  2004/05/21 21:02:53  maxx
00250 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00251 |
00252 |      Revision 1.1  2002/11/13 01:58:21  mspindle
00253 |      *** empty log message ***
00254 |
00255 |      Revision 1.5  2002/03/06 22:46:54  uzadow
00256 |      Fixed major PLAnyDec bug
00257 |
00258 |      Revision 1.4  2002/03/03 16:29:55  uzadow
00259 |      Re-added BPPWanted.
00260 |
00261 |      Revision 1.3  2001/10/21 17:12:40  uzadow
00262 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00263 |
00264 |      Revision 1.2  2001/10/06 22:03:26  uzadow
00265 |      Added PL prefix to basic data types.
00266 |
00267 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00268 |      Added global name prefix PL, changed most filenames.
00269 |
00270 |      Revision 1.8  2000/12/18 22:42:52  uzadow
00271 |      Replaced RGBAPIXEL with PLPixel32.
00272 |
00273 |      Revision 1.7  2000/03/30 21:24:15  Ulrich von Zadow
00274 |      Added MakeBmpFromMemory() function by Markus Ewald
00275 |
00276 |      Revision 1.6  2000/01/16 20:43:14  anonymous
00277 |      Removed MFC dependencies
00278 |
00279 |      Revision 1.5  2000/01/11 21:40:30  Ulrich von Zadow
00280 |      Added instance handle parameter to LoadFromResource()
00281 |
00282 |      Revision 1.4  2000/01/08 15:51:30  Ulrich von Zadow
00283 |      Misc. modifications to png encoder.
00284 |
00285 |      Revision 1.3  1999/11/08 22:12:51  Ulrich von Zadow
00286 |      Andreas Koepf: Added resource type as parameter to
00287 |      MakeBmpFromResource
00288 |
00289 |
00290 \--------------------------------------------------------------------
00291 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1