home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / win32 / include / cximage / ximatga.h < prev    next >
C/C++ Source or Header  |  2004-02-29  |  3KB  |  78 lines

  1. /*
  2.  * File:    ximatga.h
  3.  * Purpose:    TARGA Image Class Loader and Writer
  4.  */
  5. /* === C R E D I T S  &  D I S C L A I M E R S ==============
  6.  * CxImageTGA (c) 05/Jan/2002 Davide Pizzolato - www.xdp.it
  7.  * Permission is given by the author to freely redistribute and include
  8.  * this code in any program as long as this credit is given where due.
  9.  *
  10.  * CxImage version 5.99a 08/Feb/2004
  11.  * See the file history.htm for the complete bugfix and news report.
  12.  *
  13.  * Parts of the code come from Paintlib
  14.  * Copyright (c) 1996-1998 Ulrich von Zadow
  15.  *
  16.  * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
  17.  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
  18.  * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
  19.  * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
  20.  * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
  21.  * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
  22.  * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
  23.  * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  24.  * THIS DISCLAIMER.
  25.  *
  26.  * Use at your own risk!
  27.  * ==========================================================
  28.  */
  29. #if !defined(__ximaTGA_h)
  30. #define __ximaTGA_h
  31.  
  32. #include "ximage.h"
  33.  
  34. #if CXIMAGE_SUPPORT_TGA
  35.  
  36. class CxImageTGA: public CxImage
  37. {
  38. #pragma pack(1)
  39. typedef struct tagTgaHeader
  40. {
  41.     BYTE   IdLength;            // Image ID Field Length
  42.     BYTE   CmapType;            // Color Map Type
  43.     BYTE   ImageType;           // Image Type
  44.  
  45.     WORD   CmapIndex;           // First Entry Index
  46.     WORD   CmapLength;          // Color Map Length
  47.     BYTE   CmapEntrySize;       // Color Map Entry Size
  48.  
  49.     WORD   X_Origin;            // X-origin of Image
  50.     WORD   Y_Origin;            // Y-origin of Image
  51.     WORD   ImageWidth;          // Image Width
  52.     WORD   ImageHeight;         // Image Height
  53.     BYTE   PixelDepth;          // Pixel Depth
  54.     BYTE   ImagDesc;            // Image Descriptor
  55. } TGAHEADER;
  56. #pragma pack()
  57.  
  58. public:
  59.     CxImageTGA(): CxImage(CXIMAGE_FORMAT_TGA) {}
  60.  
  61. //    bool Load(const char * imageFileName){ return CxImage::Load(imageFileName,CXIMAGE_FORMAT_TGA);}
  62. //    bool Save(const char * imageFileName){ return CxImage::Save(imageFileName,CXIMAGE_FORMAT_TGA);}
  63.     bool Decode(CxFile * hFile);
  64.     bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
  65.  
  66. #if CXIMAGE_SUPPORT_ENCODE
  67.     bool Encode(CxFile * hFile);
  68.     bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }
  69. #endif // CXIMAGE_SUPPORT_ENCODE
  70. protected:
  71.     BYTE ExpandCompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, BYTE rleLeftover);
  72.     void ExpandUncompressedLine(BYTE* pDest,TGAHEADER* ptgaHead,CxFile *hFile,int width, int y, int xoffset);
  73. };
  74.  
  75. #endif
  76.  
  77. #endif
  78.