00001 #ifndef __TGA_H__
00002 #define __TGA_H__
00003
00004
00005
00006
00007
00008
00009 #include <stdlib.h>
00010 #include <stdio.h>
00011
00012 #ifdef __cplusplus
00013 extern "C"{
00014 #endif
00015
00016
00017
00018 typedef unsigned char TargaByte;
00019 typedef short TargaShort;
00020 typedef int TargaLong;
00021
00022
00023
00024
00025 #pragma pack( push, 1 )
00026
00027 typedef struct tagTARGAFILEHEADER
00028 {
00029 TargaByte idLength;
00030 TargaByte colorMapType;
00031 TargaByte imageType;
00032
00033
00034
00035 TargaShort colorMapFirstEntry;
00036 TargaShort colorMapLength;
00037 TargaByte colorMapEntrySize;
00038
00039
00040
00041 TargaShort imageOriginX;
00042 TargaShort imageOriginY;
00043 TargaShort imageWidth;
00044 TargaShort imageHeight;
00045 TargaByte imageBitsPerPixel;
00046 TargaByte imageDescriptor;
00047 }
00048 TARGAFILEHEADER;
00049
00050 #pragma pack( pop )
00051
00052
00053
00054
00055 #define TARGA_NO_COLOR_MAP 0
00056 #define TARGA_COLOR_MAP 1
00057
00058
00059
00060
00061 #define TARGA_NO_DATA 0
00062 #define TARGA_UNCOMPRESSED_COLOR_MAP 1
00063 #define TARGA_UNCOMPRESSED_TRUE_COLOR 2
00064 #define TARGA_UNCOMPRESSED_BLACK_AND_WHITE 3
00065 #define TARGA_RLE_COLOR_MAP 9
00066 #define TARGA_RLE_TRUE_COLOR 10
00067 #define TARGA_RLE_BLACK_AND_WHITE 11
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 #define TARGA_MASK_IMAGE_ORIGIN 0x30
00083 #define TARGA_MASK_ALPHA_BITS 0x0F
00084
00085
00086
00087
00088
00089
00090
00091 #define TARGA_BOTTOM_LEFT 0x00
00092 #define TARGA_BOTTOM_RIGHT 0x10
00093 #define TARGA_TOP_LEFT 0x20
00094 #define TARGA_TOP_RIGHT 0x30
00095
00096
00097
00098
00099 typedef enum
00100 {
00101 TARGA_NO_ERROR,
00102 TARGA_ERROR_OUT_OF_MEMORY,
00103 TARGA_ERROR_FILE_OPEN,
00104 TARGA_ERROR_FILE_READ,
00105 TARGA_ERROR_FILE_WRITE,
00106 TARGA_ERROR_COMPRESSION,
00107 TARGA_ERROR_UNSUPPORTED
00108 }
00109 TARGA_ERROR_CODE;
00110
00111
00112
00113
00114 typedef enum
00115 {
00116 TARGA_UNSUPPORTED,
00117 TARGA_8BIT_GRAYSCALE,
00118 TARGA_16BIT_GRAYSCALE,
00119 TARGA_24BIT_BGR,
00120 TARGA_32BIT_BGRA,
00121 TARGA_16BIT_BGR,
00122 TARGA_8BIT_INDEX_24BIT_BGR_TABLE,
00123 TARGA_8BIT_INDEX_32BIT_BGRA_TABLE,
00124 TARGA_8BIT_INDEX_16BIT_BGR_TABLE
00125 }
00126 TARGA_TYPE;
00127
00128
00129
00130
00131 typedef struct tagTARGAFILE
00132 {
00133 TARGAFILEHEADER header;
00134 void *colorMap;
00135 void *image;
00136 }
00137 TARGAFILE;
00138
00139
00140
00141
00142 TARGA_TYPE GetTargaType( TARGAFILEHEADER *header );
00143
00144 TARGA_ERROR_CODE ReadTarga( char *fileName, TARGAFILE *targa );
00145 TARGA_ERROR_CODE WriteTarga( char *fileName, TARGAFILE *targa );
00146
00147
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151
00152 #endif
00153