00001 #ifndef _libtarga_h_ 00002 #define _libtarga_h_ 00003 00004 /************************************************************************** 00005 ** Simplified TARGA library for Intro to Graphics Classes 00006 ** 00007 ** This is a simple library for reading and writing image files in 00008 ** the TARGA file format (which is a simple format). 00009 ** The routines are intentionally designed to be simple for use in 00010 ** into to graphics assignments - a more full-featured targa library 00011 ** also exists for other uses. 00012 ** 00013 ** This library was originally written by Alex Mohr who has assigned 00014 ** copyright to Michael Gleicher. The code is made available under an 00015 ** "MIT" Open Source license. 00016 **/ 00017 00021 #if defined(WIN32) 00022 00023 #if defined(DGV_DLL) 00024 /* 00025 Used for DLL generation purposes (Windows Specific) Import/Export. 00026 Templates classes cannot be imported hence its own variable. 00027 The export command is 00028 */ 00029 #if defined(CONTRIB_MAKEDLL) // create a Contrib DLL library 00030 #define CONTRIB_EXPORT __declspec(dllexport) 00031 #else // use a Contrib DLL library 00032 #define CONTRIB_EXPORT __declspec(dllimport) 00033 #endif 00034 00035 #endif // DGV_DLL 00036 00037 #endif // WIN32 00038 00039 #ifndef CONTRIB_EXPORT 00040 #define CONTRIB_EXPORT 00041 #endif 00042 00067 /* uncomment this line if you're compiling on a big-endian machine */ 00068 /* #define WORDS_BIGENDIAN */ 00069 00070 00071 /* make sure these types reflect your system's type sizes. */ 00072 #define byte char 00073 #define int32 int 00074 #define int16 short 00075 00076 #define ubyte unsigned byte 00077 #define uint32 unsigned int32 00078 #define uint16 unsigned int16 00079 00080 00081 00082 /* 00083 Truecolor images supported: 00084 00085 bits breakdown components 00086 -------------------------------------- 00087 32 8-8-8-8 RGBA 00088 24 8-8-8 RGB 00089 16 5-6-5 RGB 00090 15 5-5-5-1 RGB (ignore extra bit) 00091 00092 00093 Paletted images supported: 00094 00095 index size palette entry breakdown components 00096 ------------------------------------------------------ 00097 8 <any of above> <same as above> .. 00098 16 <any of above> <same as above> .. 00099 24 <any of above> <same as above> .. 00100 00101 */ 00102 00103 00104 00105 /* 00106 00107 Targa files are read in and converted to 00108 any of these three for you -- you choose which you want. 00109 00110 This is the 'format' argument to tga_create/load/write. 00111 00112 For create and load, format is what you want the data 00113 converted to. 00114 00115 For write, format is what format the data you're writing 00116 is in. (NOT the format you want written) 00117 00118 Only TGA_TRUECOLOR_32 supports an alpha channel. 00119 00120 */ 00121 00122 #define TGA_TRUECOLOR_32 (4) 00123 #define TGA_TRUECOLOR_24 (3) 00124 00125 00126 /* 00127 Image data will start in the low-left corner 00128 of the image. 00129 */ 00130 00131 00132 /* Error handling routines */ 00133 CONTRIB_EXPORT int tga_get_last_error(); 00134 CONTRIB_EXPORT const char * tga_error_string( int error_code ); 00135 00136 00137 /* Creating/Loading images -- a return of NULL indicates a fatal error */ 00138 CONTRIB_EXPORT void * tga_create( int width, int height, unsigned int format ); 00139 CONTRIB_EXPORT void * tga_load( const char * file, int * width, int * height, unsigned int format ); 00140 00141 00142 /* Writing images to file -- a return of 1 indicates success, 0 indicates error*/ 00143 CONTRIB_EXPORT int tga_write_raw( const char * file, int width, int height, unsigned char * dat, unsigned int format ); 00144 CONTRIB_EXPORT int tga_write_rle( const char * file, int width, int height, unsigned char * dat, unsigned int format ); 00145 00146 00147 #endif /* _libtarga_h_ */