Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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