

typedef struct {
  u_int8_t Blue;
  u_int8_t Green;
  u_int8_t Red;
} RGBStruct24;

typedef struct {
  unsigned Alpha : 1;
  unsigned Red   : 5;
  unsigned Green : 5;
  unsigned Blue  : 5;
} RGBStruct16;


typedef struct {
  u_int8_t  IDLength;       // 0    c
  u_int8_t  MapType;        // 1
  u_int8_t  ImageType;      // 2
  u_int16_t MapOrigin;      // 3,4
  u_int16_t MapLength;      // 5,6  c
  u_int8_t  MapDepth;       // 7
  u_int16_t XOrigin;        // 8,9
  u_int16_t YOrigin;        // 10,11 
  u_int16_t Width;          // 12,13 c
  u_int16_t Height;         // 14,15 c
  u_int8_t  PixelSize;      // 16    c
  u_int8_t  ImageDescriptor;// 17    c
} TgaHeader;

typedef struct {
  u_int16_t ImageOffset;
  u_int16_t PalletteOffset;

  u_int16_t Height;
  u_int16_t Width;
    
  u_int8_t bpp;
  u_int8_t PixelOrder;

  RGBStruct24 Pallette[257];    //!!!???!!! dosn't handle 16bit palleted files "yet"

  int handle; //file handle  
  //char  head[18]; //header copy
  TgaHeader head;
  
} TgaStruct;

int init_tga_read(const char *fileName, TgaStruct* info); // use to open file
int open_tga(TgaHeader *header, const char *fileName); // internal
RGBStruct24 get_tga_pixel(TgaStruct* info, u_int16_t X, u_int16_t Y); // data reader
int fin_tga_read(TgaStruct* info); // use to close file
