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

plpictdec.h

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plpictdec.h,v 1.1 2004/05/21 21:02:53 maxx Exp $
00005 |
00006 |      Copyright (c) 1996-1998 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLPICTDEC
00012 #define INCL_PLPICTDEC
00013 
00014 #ifndef INCL_PLPICDEC
00015 #include "plpicdec.h"
00016 #endif
00017 
00018 #include "qdraw.h"
00019 
00020 class PLJPEGDecoder;
00021 
00028 class PLPictDecoder : public PLPicDecoder
00029 {
00030 
00031 
00032 public:
00035   PLPictDecoder
00036     ( PLJPEGDecoder * pJPEGDecoder
00037     );
00038 
00040   virtual ~PLPictDecoder
00041     ();
00042 
00043 protected:
00045   virtual void DoDecode
00046     ( PLBmp * pBmp,
00047       PLDataSource * pDataSrc
00048     );
00049 
00050 private:
00051   // Decodes header and version information.
00052   // Sets m_Version.
00053   // Performs checks to make sure the data is really a pict file.
00054   void readHeader
00055     ( PLDataSource * pDataSrc,
00056       int& Version
00057     );
00058 
00059   // This is the main decoder loop. The functions reads opcodes,
00060   // skips some of them, and hands the rest to opcode-specific
00061   // functions. It stops decoding after the first opcode containing
00062   // bitmapped data.
00063   void interpretOpcodes
00064     ( PLBmp * pBmp,
00065       PLDataSource * pDataSrc,
00066       int& Version
00067     );
00068 
00069   // Moves to an even byte position in the file and returns the
00070   // opcode found there.
00071   PLWORD readOpcode
00072     ( int Version,
00073       PLDataSource * pDataSrc
00074     );
00075 
00076   // Opcode functions
00077 
00078   // Skips clipping rectangle or region opcode.
00079   void clip
00080     ( PLDataSource * pDataSrc
00081     );
00082 
00083   // Skips pattern definition opcode.
00084   // Untested!!
00085   void pixPat
00086     ( PLDataSource * pDataSrc
00087     );
00088 
00089   // Skips polygon/region opcodes.
00090   // Untested!!
00091   void skipPolyOrRegion
00092     ( PLDataSource * pDataSrc
00093     );
00094 
00095   // Opcode: Bitmap/pixmap data clipped by a rectangle.
00096   void bitsRect
00097     ( PLDataSource * pDataSrc,
00098       PLBmp * pBmp
00099     );
00100 
00101   // Opcode: Bitmap/pixmap data clipped by a region.
00102   void bitsRegion
00103     ( PLDataSource * pDataSrc,
00104       PLBmp * pBmp
00105     );
00106 
00107   // DirectBitsRect opcode.
00108   void opcode9a
00109     ( PLDataSource * pDataSrc,
00110       PLBmp * pBmp
00111     );
00112 
00113   // Long comment opcode. Skipped.
00114   void longComment
00115     ( PLDataSource * pDataSrc
00116     );
00117 
00118   // Header opcode. Contains resolution information.
00119   void headerOp 
00120     ( PLDataSource * pDataSrc,
00121       PLBmp * pBmp
00122     );
00123 
00124   // JPEG opcode. Invoke the JPEG decoder for this PICT.
00125   void jpegOp
00126     ( PLDataSource * pDataSrc,
00127       PLBmp * pBmp
00128     );
00129 
00130   // Bitmap & Pixmap functions.
00131 
00132   // Allocates the output bitmap.
00133   void createOutputBmp
00134     ( MacpixMap PixMap,
00135       PLBmp * pBmp
00136     );
00137 
00138   // Decode version 1 bitmap: 1 bpp.
00139   void doBitmap
00140     ( int rowBytes,
00141       bool bIsRegion,
00142       PLBmp * pBmp,
00143       PLDataSource * pDataSrc
00144     );
00145 
00146   // Decode version 2 pixmap.
00147   void doPixmap
00148     ( int rowBytes,
00149       bool bIsRegion,
00150       PLBmp * pBmp,
00151       PLDataSource * pDataSrc
00152     );
00153 
00154   // This routine decompresses BitsRects with a packType of 4 (and
00155   // 32 bits per pixel). In this format, each line is separated
00156   // into 8-bit-bitplanes and then compressed via RLE. To decode,
00157   // the routine decompresses each line & then juggles the bytes
00158   // around to get pixel-oriented data.
00159   void unpack32bits
00160     ( MacRect* pBounds,
00161       PLWORD rowBytes,
00162       int NumBitPlanes,    // 3 if RGB, 4 if RGBA
00163       PLBmp * pBmp,
00164       PLDataSource * pDataSrc
00165     );
00166 
00167   // Decompression routine for 8 bpp. rowBytes is the number of
00168   // bytes each source row would take if it were uncompressed.
00169   // This _isn't_ equal to the number of pixels in the row - apple
00170   // pads the data to a word boundary and then compresses it. Of
00171   // course, we have to decompress the excess data and then throw it
00172   // away.
00173   void unpack8bits
00174     ( MacRect* pBounds,
00175       PLWORD rowBytes,
00176       PLBmp * pBmp,
00177       PLDataSource * pDataSrc
00178     );
00179 
00180   // Decompression routine for everything but 32 bpp. This routine
00181   // is slower than the two routines above since it has to deal
00182   // with a lot of special cases.
00183   void unpackbits
00184     ( MacRect* pBounds,
00185       PLWORD rowBytes,
00186       int pixelSize,         // Source bits per pixel.
00187       PLBmp * pBmp,
00188       PLDataSource * pDataSrc
00189     );
00190 
00191   // Skips unneeded packbits.
00192   void skipBits
00193     ( MacRect* pBounds,
00194       PLWORD rowBytes,
00195       int pixelSize,         // Source bits per pixel.
00196       PLDataSource * pDataSrc
00197     );
00198 
00199   // Expands one RLE unit to 32-bit pixel data.
00200   void expandBuf
00201     ( PLBYTE * pDestBuf,
00202       PLBYTE * pSrcBuf,
00203       int Width,       // Width in bytes for 8 bpp or less.
00204                        // Width in pixels for 16 bpp.
00205       int bpp          // bits per pixel
00206     );
00207 
00208   // Expands Width units to 8-bit pixel data.
00209   // Max. 8 bpp source format.
00210   void expandBuf8
00211     ( PLBYTE * pDestBuf,
00212       PLBYTE * pSrcBuf,
00213       int Width,       // Width in bytes.
00214       int bpp          // bits per pixel.
00215     );
00216 
00217   void readPixmap
00218     ( MacpixMap * pPixMap,
00219       PLDataSource * pDataSrc
00220     );
00221 
00222   // Reads a mac colour table into a windows palette.
00223   void readColourTable
00224     ( PLWORD * pNumColors,
00225       PLDataSource * pDataSrc,
00226       PLPixel32 * pPal
00227     );
00228 
00229   void readRect
00230     ( MacRect * pr,
00231       PLDataSource * pDataSrc
00232     );
00233 
00234   void dumpRect
00235     ( char * psz,
00236       MacRect * pr
00237     );
00238 
00239   void tracePixMapHeader
00240     ( int Level,
00241       MacpixMap * pPixMap
00242     );
00243 
00244 
00245   PLJPEGDecoder * m_pJPEGDecoder; // Used if a pict file contains a JPEG.
00246   PLPoint m_Resolution;
00247 
00248 };
00249 
00250 #endif
00251 /*
00252 /--------------------------------------------------------------------
00253 |
00254 |      $Log: plpictdec.h,v $
00255 |      Revision 1.1  2004/05/21 21:02:53  maxx
00256 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00257 |
00258 |      Revision 1.1  2002/11/13 01:58:22  mspindle
00259 |      *** empty log message ***
00260 |
00261 |      Revision 1.5  2001/10/21 17:12:40  uzadow
00262 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00263 |
00264 |      Revision 1.4  2001/10/16 17:12:26  uzadow
00265 |      Added support for resolution information (Luca Piergentili)
00266 |
00267 |      Revision 1.3  2001/10/06 22:03:26  uzadow
00268 |      Added PL prefix to basic data types.
00269 |
00270 |      Revision 1.2  2001/10/03 13:58:21  uzadow
00271 |      Removed references to config.h
00272 |
00273 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00274 |      Added global name prefix PL, changed most filenames.
00275 |
00276 |
00277 \--------------------------------------------------------------------
00278 */

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