Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

plpsddec.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plpsddec.h,v 1.4 2002/11/18 14:45:10 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLPSDDEC
00012 #define INCL_PLPSDDEC
00013 
00014 #ifndef INCL_PLPICDEC
00015 #include "plpicdec.h"
00016 #endif
00017 
00018 #include <vector>
00019 
00020 class PLDataSource;
00021 class PLPoint;
00022 
00023 struct PLPSDHeader
00024 {
00025   char     Signature[4];
00026   PLWORD   Version;
00027   PLBYTE   Reserved[6];
00028   PLWORD   Channels;
00029   int      Rows;
00030   int      Columns;
00031   PLWORD   BPP;
00032   PLWORD   Mode;
00033 };
00034 
00035 struct PLPSDLayerInfo;
00036 
00037 //! Photoshop file decoder. Besides having the MakeBmpFromFile interface
00038 //! that the other decoders have, the photoshop decoder loads the layers
00039 //! of the image into separate bitmaps so they can be manipulated separately:
00040 //! <pre>
00041 //!   vector&lt;PLAnyBmp&gt; Bmp;
00042 //!   PLAnyBmp BaseBmp);
00043 //!   Decoder-&gt;OpenFile ("face.psd");
00044 //!   int NumLayers = Decoder-&gt;GetNumLayers();
00045 //!   for (int i=0; i&lt;NumLayers; i++)
00046 //!   {
00047 //!     GetNextLayer (Bmp[i]);
00048 //!     LayerOffset = GetLayerOffset();
00049 //!   }
00050 //!   GetImage (&BaseBmp);
00051 //!   Close();
00052 //! </pre>
00053 class PLPSDDecoder : public PLPicDecoder
00054 {
00055 public:
00056   //! Creates a decoder
00057   PLPSDDecoder
00058     ();
00059 
00060   //! Destroys a decoder
00061   virtual ~PLPSDDecoder
00062     ();
00063 
00064   //!
00065   virtual void Open (PLDataSource * pDataSrc);
00066 
00067   //! Fills the bitmap with the main image. This image is a flattened 
00068   //! version of the layers.
00069   virtual void GetImage (PLBmp & pBmp);
00070 
00071   //! Returns number of layers in the image.
00072   int GetNumLayers
00073     ();
00074 
00075   //! Fills the bitmap with the layer data.
00076   void GetNextLayer
00077     ( PLBmp& Bmp
00078     );
00079 
00080   //! Returns the origin of the layer data in the image.
00081   PLPoint GetLayerOffset
00082     ();
00083 
00084 private:
00085   void readHeader
00086     ( PLDataSource * pDataSrc,
00087       PLPSDHeader * pPSDHeader
00088     );
00089 
00090   void readColorModeData 
00091     ( PLDataSource * pDataSrc
00092     );
00093 
00094   PLBmpInfo* createBmpInfo 
00095     ( int Mode,
00096       int Height,
00097       int Width,
00098       int Channels,
00099       const PLPoint& Resolution
00100     );
00101 
00102   void readImageResData 
00103     ( PLDataSource * pDataSrc,
00104       PLPoint& Resolution
00105     );
00106 
00107   void readLayerHeader 
00108     ( PLDataSource * pDataSrc
00109     );
00110 
00111   void skipLayerData
00112     ( PLDataSource * pDataSrc
00113     );
00114 
00115   void skipMaskData
00116     ( PLDataSource * pDataSrc
00117     );
00118 
00119   void readLayer 
00120     ( PLDataSource * pDataSrc, 
00121       PLBmp& Bmp,
00122       int Mode
00123     );
00124 
00125   void readImageData
00126     ( PLDataSource * pDataSrc,
00127       PLBmp * pBmp,
00128       int Mode,
00129       int Height,
00130       int Width,
00131       int Channels 
00132     );
00133 
00134   void traceCompressionMethod
00135     ( PLWORD CompressionMethod
00136     );
00137 
00138   void readUncompressedImage 
00139     ( PLDataSource * pDataSrc,
00140       PLBmp * pBmp,
00141       int Mode,
00142       int Height,
00143       int Width,
00144       int Channels 
00145     );
00146 
00147   void readRLEImage 
00148     ( PLDataSource * pDataSrc,
00149       PLBmp * pBmp,
00150       int Mode,
00151       int Height,
00152       int Width,
00153       int Channels 
00154     );
00155 
00156   void readRLEChannel 
00157     ( PLDataSource * pDataSrc,
00158       PLBmp * pBmp,
00159       int Mode,
00160       int Height,
00161       int Width,
00162       int ChannelNum,
00163       int * pRowLengths 
00164     );
00165 
00166   void cleanup
00167     ();
00168 
00169   PLPSDHeader m_PSDHeader;
00170   PLPoint m_Resolution;
00171   PLPixel32 m_pPal[256];
00172   PLBYTE * m_pMiscDataStart;
00173   int m_MiscDataSize;
00174   int m_NumLayers;
00175   int m_LayersRead;
00176   std::vector<PLPSDLayerInfo *> m_pLayerInfo;
00177 };
00178 
00179 #endif
00180 
00181 /*
00182 /--------------------------------------------------------------------
00183 |
00184 |      $Log: plpsddec.h,v $
00185 |      Revision 1.4  2002/11/18 14:45:10  uzadow
00186 |      Added PNG compression support, fixed docs.
00187 |
00188 |      Revision 1.3  2002/08/04 20:08:01  uzadow
00189 |      Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support.
00190 |
00191 |      Revision 1.2  2002/03/31 13:36:42  uzadow
00192 |      Updated copyright.
00193 |
00194 |      Revision 1.1  2001/10/21 17:12:40  uzadow
00195 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00196 |
00197 |
00198 \--------------------------------------------------------------------
00199 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2