3 * Purpose: TARGA Image Class Loader and Writer
5 /* ==========================================================
6 * CxImageTGA (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it
7 * For conditions of distribution and use, see copyright notice in ximage.h
9 * Parts of the code come from Paintlib : Copyright (c) 1996-1998 Ulrich von Zadow
10 * ==========================================================
12 #if !defined(__ximaTGA_h)
17 #if CXIMAGE_SUPPORT_TGA
19 class CxImageTGA: public CxImage
22 typedef struct tagTgaHeader
24 BYTE IdLength; // Image ID Field Length
25 BYTE CmapType; // Color Map Type
26 BYTE ImageType; // Image Type
28 WORD CmapIndex; // First Entry Index
29 WORD CmapLength; // Color Map Length
30 BYTE CmapEntrySize; // Color Map Entry Size
32 WORD X_Origin; // X-origin of Image
33 WORD Y_Origin; // Y-origin of Image
34 WORD ImageWidth; // Image Width
35 WORD ImageHeight; // Image Height
36 BYTE PixelDepth; // Pixel Depth
37 BYTE ImagDesc; // Image Descriptor
42 CxImageTGA(): CxImage(CXIMAGE_FORMAT_TGA) {}
44 // bool Load(const TCHAR * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TGA);}
45 // bool Save(const TCHAR * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TGA);}
46 bool Decode(CxFile * hFile);
47 bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
49 #if CXIMAGE_SUPPORT_ENCODE
50 bool Encode(CxFile * hFile);
51 bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }
52 #endif // CXIMAGE_SUPPORT_ENCODE
54 BYTE ExpandCompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, BYTE rleLeftover);
55 void ExpandUncompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, int xoffset);
56 void tga_toh(TGAHEADER* p);