gKit2 light
Loading...
Searching...
No Matches
rgbe.h
1#ifndef _H_RGBE
2#define _H_RGBE
3/* THIS CODE CARRIES NO GUARANTEE OF USABILITY OR FITNESS FOR ANY PURPOSE.
4 * WHILE THE AUTHORS HAVE TRIED TO ENSURE THE PROGRAM WORKS CORRECTLY,
5 * IT IS STRICTLY USE AT YOUR OWN RISK. */
6
7/* utility for reading and writing Ward's rgbe image format.
8 See rgbe.txt file for more details.
9*/
10
11#include <cstdio>
12
13typedef struct {
14 int valid; /* indicate which fields are valid */
15 char programtype[16]; /* listed at beginning of file to identify it
16 * after "#?". defaults to "RGBE" */
17 float gamma; /* image has already been gamma corrected with
18 * given gamma. defaults to 1.0 (no correction) */
19 float exposure; /* a value of 1.0 in an image corresponds to
20 * <exposure> watts/steradian/m^2.
21 * defaults to 1.0 */
23
24/* flags indicating which fields in an rgbe_header_info are valid */
25#define RGBE_VALID_PROGRAMTYPE 0x01
26#define RGBE_VALID_GAMMA 0x02
27#define RGBE_VALID_EXPOSURE 0x04
28
29/* return codes for rgbe routines */
30#define RGBE_RETURN_SUCCESS 0
31#define RGBE_RETURN_FAILURE -1
32
33/* read or write headers */
34/* you may set rgbe_header_info to null if you want to */
35int RGBE_WriteHeader(FILE *fp, const int width, const int height, const rgbe_header_info *info);
36int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info);
37
38/* read or write pixels */
39/* can read or write pixels in chunks of any size including single pixels*/
40int RGBE_WritePixels(FILE *fp, const float *data, const int numpixels);
41int RGBE_ReadPixels(FILE *fp, float *data, const int numpixels);
42
43/* read or write run length encoded files */
44/* must be called to read or write whole scanlines */
45int RGBE_WritePixels_RLE(FILE *fp, const float *data, const int scanline_width, const int num_scanlines);
46int RGBE_ReadPixels_RLE(FILE *fp, float *data, const int scanline_width, const int num_scanlines);
47
48#endif /* _H_RGBE */
49
50
51