llimagetga.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLIMAGETGA_H
00033 #define LL_LLIMAGETGA_H
00034 
00035 #include "llimage.h"
00036 
00037 // This class compresses and decompressed TGA (targa) files
00038 
00039 class LLImageTGA : public LLImageFormatted
00040 {
00041 protected:
00042         virtual ~LLImageTGA();
00043         
00044 public:
00045         LLImageTGA();
00046         LLImageTGA(const LLString& file_name);
00047 
00048         /*virtual*/ BOOL updateData();
00049         /*virtual*/ BOOL decode(LLImageRaw* raw_image, F32 decode_time=0.0);
00050         /*virtual*/ BOOL encode(const LLImageRaw* raw_image, F32 encode_time=0.0);
00051 
00052         BOOL                     decodeAndProcess(LLImageRaw* raw_image, F32 domain, F32 weight);
00053         
00054 private:
00055         BOOL                     decodeTruecolor( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
00056 
00057         BOOL                     decodeTruecolorRle8( LLImageRaw* raw_image );
00058         BOOL                     decodeTruecolorRle15( LLImageRaw* raw_image );
00059         BOOL                     decodeTruecolorRle24( LLImageRaw* raw_image );
00060         BOOL                     decodeTruecolorRle32( LLImageRaw* raw_image, BOOL &alpha_opaque );
00061 
00062         void                     decodeTruecolorPixel15( U8* dst, const U8* src );
00063 
00064         BOOL                     decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaque );
00065         
00066         BOOL                     decodeColorMap( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
00067 
00068         void                     decodeColorMapPixel8(U8* dst, const U8* src);
00069         void                     decodeColorMapPixel15(U8* dst, const U8* src);
00070         void                     decodeColorMapPixel24(U8* dst, const U8* src);
00071         void                     decodeColorMapPixel32(U8* dst, const U8* src);
00072 
00073         bool                     loadFile(const LLString& file_name);
00074         
00075 private:
00076         // Class specific data
00077         U32 mDataOffset; // Offset from start of data to the actual header.
00078 
00079         // Data from header
00080         U8 mIDLength;           // Length of identifier string
00081         U8 mColorMapType;       // 0 = No Map
00082         U8 mImageType;          // Supported: 2 = Uncompressed true color, 3 = uncompressed monochrome without colormap
00083         U8 mColorMapIndexLo;    // First color map entry (low order byte)
00084         U8 mColorMapIndexHi;    // First color map entry (high order byte)
00085         U8 mColorMapLengthLo;   // Color map length (low order byte)
00086         U8 mColorMapLengthHi;   // Color map length (high order byte)
00087         U8 mColorMapDepth;      // Size of color map entry (15, 16, 24, or 32 bits)
00088         U8 mXOffsetLo;          // X offset of image (low order byte)
00089         U8 mXOffsetHi;          // X offset of image (hi order byte)
00090         U8 mYOffsetLo;          // Y offset of image (low order byte)
00091         U8 mYOffsetHi;          // Y offset of image (hi order byte)
00092         U8 mWidthLo;            // Width (low order byte)
00093         U8 mWidthHi;            // Width (hi order byte)
00094         U8 mHeightLo;           // Height (low order byte)
00095         U8 mHeightHi;           // Height (hi order byte)
00096         U8 mPixelSize;          // 8, 16, 24, 32 bits per pixel
00097         U8 mAttributeBits;      // 4 bits: number of attributes per pixel
00098         U8 mOriginRightBit;     // 1 bit: origin, 0 = left, 1 = right
00099         U8 mOriginTopBit;       // 1 bit: origin, 0 = bottom, 1 = top
00100         U8 mInterleave;         // 2 bits: interleaved flag, 0 = none, 1 = interleaved 2, 2 = interleaved 4
00101 
00102         U8*             mColorMap;
00103         S32             mColorMapStart;
00104         S32             mColorMapLength; 
00105         S32             mColorMapBytesPerEntry;
00106 
00107         BOOL    mIs15Bit;
00108 
00109         static const U8 s5to8bits[32];
00110 };
00111 
00112 #endif

Generated on Thu Jul 1 06:08:44 2010 for Second Life Viewer by  doxygen 1.4.7