Subversion Repositories gelsvn

Rev

Rev 594 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
594 jab 1
/**
2
 * @file image_helper.h
3
 * @brief Image helper functions
4
 */
369 jab 5
/*
6
    Jonathan Dummer
7
 
8
    Image helper functions
9
 
10
    MIT license
11
*/
12
 
13
#ifndef HEADER_IMAGE_HELPER
14
#define HEADER_IMAGE_HELPER
15
 
16
#ifdef __cplusplus
17
extern "C" {
18
#endif
19
 
20
/**
21
	This function upscales an image.
22
	Not to be used to create MIPmaps,
23
	but to make it square,
24
	or to make it a power-of-two sized.
25
**/
26
int
27
	up_scale_image
28
	(
29
		const unsigned char* const orig,
30
		int width, int height, int channels,
31
		unsigned char* resampled,
32
		int resampled_width, int resampled_height
33
	);
34
 
35
/**
36
	This function downscales an image.
37
	Used for creating MIPmaps,
38
	the incoming image should be a
39
	power-of-two sized.
40
**/
41
int
42
	mipmap_image
43
	(
44
		const unsigned char* const orig,
45
		int width, int height, int channels,
46
		unsigned char* resampled,
47
		int block_size_x, int block_size_y
48
	);
49
 
50
/**
51
	This function takes the RGB components of the image
52
	and scales each channel from [0,255] to [16,235].
53
	This makes the colors "Safe" for display on NTSC
54
	displays.  Note that this is _NOT_ a good idea for
55
	loading images like normal- or height-maps!
56
**/
57
int
58
	scale_image_RGB_to_NTSC_safe
59
	(
60
		unsigned char* orig,
61
		int width, int height, int channels
62
	);
63
 
64
/**
65
	This function takes the RGB components of the image
66
	and converts them into YCoCg.  3 components will be
67
	re-ordered to CoYCg (for optimum DXT1 compression),
68
	while 4 components will be ordered CoCgAY (for DXT5
69
	compression).
70
**/
71
int
72
	convert_RGB_to_YCoCg
73
	(
74
		unsigned char* orig,
75
		int width, int height, int channels
76
	);
77
 
78
/**
79
	This function takes the YCoCg components of the image
80
	and converts them into RGB.  See above.
81
**/
82
int
83
	convert_YCoCg_to_RGB
84
	(
85
		unsigned char* orig,
86
		int width, int height, int channels
87
	);
88
 
89
/**
90
	Converts an HDR image from an array
91
	of unsigned chars (RGBE) to RGBdivA
92
	\return 0 if failed, otherwise returns 1
93
**/
94
int
95
	RGBE_to_RGBdivA
96
	(
97
		unsigned char *image,
98
		int width, int height,
99
		int rescale_to_max
100
	);
101
 
102
/**
103
	Converts an HDR image from an array
104
	of unsigned chars (RGBE) to RGBdivA2
105
	\return 0 if failed, otherwise returns 1
106
**/
107
int
108
	RGBE_to_RGBdivA2
109
	(
110
		unsigned char *image,
111
		int width, int height,
112
		int rescale_to_max
113
	);
114
 
115
#ifdef __cplusplus
116
}
117
#endif
118
 
119
#endif /* HEADER_IMAGE_HELPER	*/