summary refs log tree commit diff stats
path: root/libs/cocos2d/Support/TGAlib.h
blob: 247084ecb5e3ddb33fad7e02a64c0e1ccc2e3135 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// TGA lib for cocos2d-iphone
//
// sources from: http://www.lighthouse3d.com/opengl/terrain/index.php3?tgasource
//

//#ifndef TGA_LIB
//#define TGA_LIB

/**
 @file
 TGA image support
 */

enum {
	TGA_OK,
	TGA_ERROR_FILE_OPEN,
	TGA_ERROR_READING_FILE,
	TGA_ERROR_INDEXED_COLOR,
	TGA_ERROR_MEMORY,
	TGA_ERROR_COMPRESSED_FILE,
};

/** TGA format */
typedef struct sImageTGA {
	int status;
	unsigned char type, pixelDepth;
	
	/** map width */
	short int width;
	
	/** map height */
	short int height;
	
	/** raw data */
	unsigned char *imageData;
	int flipped;
} tImageTGA;

/// load the image header fields. We only keep those that matter!
void tgaLoadHeader(FILE *file, tImageTGA *info);

/// loads the image pixels. You shouldn't call this function directly
void tgaLoadImageData(FILE *file, tImageTGA *info);

/// this is the function to call when we want to load an image
tImageTGA * tgaLoad(const char *filename);

// /converts RGB to greyscale
void tgaRGBtogreyscale(tImageTGA *info);

/// releases the memory used for the image
void tgaDestroy(tImageTGA *info);

//#endif // TGA_LIB