00001 /* 00002 /-------------------------------------------------------------------- 00003 | 00004 | $Id: pltgadec.h,v 1.5 2002/08/04 20:08:01 uzadow Exp $ 00005 | 00006 | Copyright (c) 1996-2002 Ulrich von Zadow 00007 | 00008 \-------------------------------------------------------------------- 00009 */ 00010 00011 #ifndef INCL_PLTGADEC 00012 #define INCL_PLTGADEC 00013 00014 #ifndef INCL_PLPICDEC 00015 #include "plpicdec.h" 00016 #endif 00017 00018 #ifndef INCL_PLTGA 00019 #include "pltga.h" 00020 #endif 00021 00022 //! Targa file decoder. Decodes 8, 15, 16, 24 and 32 bpp 00023 //! targa files (compressed and uncompressed) and returns an 8 or 32 00024 //! bpp CBitmap. Preserves the alpha channel. 00025 class PLTGADecoder : public PLPicDecoder 00026 { 00027 00028 00029 public: 00030 //! Creates a decoder 00031 PLTGADecoder 00032 (); 00033 00034 //! Destroys a decoder 00035 virtual ~PLTGADecoder 00036 (); 00037 00038 //! 00039 virtual void Open (PLDataSource * pDataSrc); 00040 00041 //! Fills the bitmap with the image. 00042 virtual void GetImage (PLBmp & Bmp); 00043 00044 private: 00045 00046 // Fills TGAHEADER structure with the information in the file. 00047 void readTgaHeader 00048 ( TGAHEADER * pTgaHead, // Pointer to TGA header structure 00049 PLDataSource * pDataSrc 00050 ); 00051 00052 // Reads the TGA palette and creates a windows palette. 00053 void readPalette 00054 ( int StartIndex, // Index of first palette entry. 00055 int Length, // Number of palette entries stored. 00056 int EntrySize, // Size of palette entries in bits. 00057 PLBmp * pBmp, 00058 PLDataSource * pDataSrc 00059 ); 00060 00061 00062 // Determines compression type and calls readData. 00063 void readImage 00064 ( TGAHEADER * pTgaHead, // Pointer to TGA header structure 00065 PLBmp * pBmp, 00066 PLDataSource * pDataSrc 00067 ); 00068 00069 // Reads image data line-by-line. 00070 void readData 00071 ( TGAHEADER * pTgaHead, // Pointer to TGA header structure 00072 bool bCompressed, 00073 PLBmp * pBmp, 00074 PLDataSource * pDataSrc 00075 ); 00076 00077 // Decodes one line of uncompressed image data. 00078 void expandUncompressedLine 00079 ( PLBYTE * pDest, 00080 int Width, 00081 bool bReversed, 00082 int bpp, 00083 PLDataSource * pDataSrc 00084 ); 00085 00086 // Decodes one line of compressed image data. 00087 void expandCompressedLine 00088 ( PLBYTE * pDest, 00089 int Width, 00090 bool bReversed, 00091 int bpp, 00092 PLDataSource * pDataSrc 00093 ); 00094 00095 // Reads one image pixel and returns it in RGBA format. 00096 PLPixel32 readPixel32 00097 ( int bpp, 00098 PLDataSource * pDataSrc 00099 ); 00100 00101 // Reads one image pixel and returns it in 8-bit format. 00102 PLBYTE readPixel8 00103 ( int bpp, 00104 PLDataSource * pDataSrc 00105 ); 00106 00107 TGAHEADER m_TgaHead; 00108 }; 00109 00110 #endif 00111 /* 00112 /-------------------------------------------------------------------- 00113 | 00114 | $Log: pltgadec.h,v $ 00115 | Revision 1.5 2002/08/04 20:08:01 uzadow 00116 | Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support. 00117 | 00118 | Revision 1.4 2002/03/31 13:36:42 uzadow 00119 | Updated copyright. 00120 | 00121 | Revision 1.3 2001/10/21 17:12:40 uzadow 00122 | Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel. 00123 | 00124 | Revision 1.2 2001/10/06 22:37:08 uzadow 00125 | Linux compatibility. 00126 | 00127 | Revision 1.1 2001/09/16 19:03:22 uzadow 00128 | Added global name prefix PL, changed most filenames. 00129 | 00130 | 00131 \-------------------------------------------------------------------- 00132 */