Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

SHAtranslatorTga.h

Go to the documentation of this file.
00001 
00010 #ifndef _SHATRANSLATORTGA_H_
00011 #define _SHATRANSLATORTGA_H_
00012 
00013 #include "SHAtranslator/SHAtranslatorImage.h"
00014 
00026 class SHAtranslatorTga : public SHAtranslatorImage
00027 {
00028 
00029 public:
00030   SHAtranslatorTga();
00031 
00032   virtual const char **Extension(void) const;
00033 
00034   virtual int Test(SHAstream * inStream);
00035 
00036   virtual int Info(SHAstream * inStream,
00037                    SHAtranslatorResult * result);
00038 
00039   virtual int Load(SHAstream * outStream,
00040                    SHAstream * inStream,
00041                    SHAtranslatorResult * result);
00042 
00043   virtual int Save(SHAstream * outStream,
00044                    SHAstream * inStream,
00045                    SHAtranslatorResult * result);
00046 
00047 private:
00049 
00050   struct TGAfileHeader
00051   {
00052     char    idfield_size[1];  
00053     char    colormap_type[1]; 
00054     char    type[1];          
00055 
00056     char    colormap_org[2];  
00057     char    colormap_n[2];    
00058     char    colormap_bit[1];  
00059 
00060     char    xorg[2];          
00061     char    yorg[2];          
00062     char    w[2];             
00063     char    h[2];             
00064     char    bpp[1];           
00065     char    descriptor[1];    
00066   };
00067 
00068   struct TGAheader
00069   {
00070     unsigned int idfield_size;  
00071     unsigned int colormap_type; 
00072     unsigned int type;          
00073     unsigned int colormap_org;  
00074     unsigned int colormap_n;    
00075     unsigned int colormap_bit;  
00076     unsigned int xorg;          
00077     unsigned int yorg;          
00078     unsigned int w;             
00079     unsigned int h;             
00080     unsigned int bpp;           
00081     unsigned int descriptor;    
00082 
00083     TGAheader();
00084     void operator = (const TGAfileHeader & fHd);
00085 
00086   };
00087 
00088   static int RGBtype(int bpp, int alphaBit);
00089 
00090   int ReadHeader(SHAtranslatorResult *result, TGAheader * hd, SHAstream * inStream) const;
00091   int CheckHeader(SHAtranslatorResult *result, TGAheader * hd) const;
00092   int ReadCheckHeader(SHAtranslatorResult *result, TGAheader * hd, SHAstream * inStream) const;
00093   int ConvertType(SHAtranslatorResult *result, TGAheader * hd) const;
00094   int GetConvertor(SHAtranslatorResult * result, TGAheader * hd, void ** rgbConvertor, void ** pixelConvertor) const;
00095 
00096 
00097   int ReadLine(SHAtranslatorResult * result, unsigned char *dest, SHAstream * in, int width, int bytePerPix) const;
00098   int ReadRleLine(SHAtranslatorResult * result, unsigned char *dest, SHAstream * in, int width, int bytePerPix) const;
00099   int RleLineOffset(SHAtranslatorResult * result, SHAstreamPos * linePos, SHAstream * in, int width, int height, int bytePerPix) const;
00100   void HorizontalFlip(unsigned char *pix, int w, int bytePerPix) const;
00101 
00102   enum Format_e {
00103     NODATA   = 0,
00104     PAL      = 1,
00105     RGB      = 2,
00106     GREY     = 3,
00107     RLEPAL   = 9,
00108     RLERGB   = 10,
00109     RLEGREY  = 11,
00110         HUFF_RLE_DELTA_PAL = 32,
00111         HUFF_RLE_DELTA_QTREE_PAL = 33
00112   };
00113 
00114 };
00115 
00116 #endif //#define _SHATRANSLATORTGA_H_

dcplaya documentation version 2.0 Generated on November 2004 by doxygen 1.3.6