gKitGL
|
00001 #ifndef _H_RGBE 00002 #define _H_RGBE 00003 /* THIS CODE CARRIES NO GUARANTEE OF USABILITY OR FITNESS FOR ANY PURPOSE. 00004 * WHILE THE AUTHORS HAVE TRIED TO ENSURE THE PROGRAM WORKS CORRECTLY, 00005 * IT IS STRICTLY USE AT YOUR OWN RISK. */ 00006 00007 /* utility for reading and writing Ward's rgbe image format. 00008 See rgbe.txt file for more details. 00009 */ 00010 00011 #include <stdio.h> 00012 00013 typedef struct { 00014 int valid; /* indicate which fields are valid */ 00015 char programtype[16]; /* listed at beginning of file to identify it 00016 * after "#?". defaults to "RGBE" */ 00017 float gamma; /* image has already been gamma corrected with 00018 * given gamma. defaults to 1.0 (no correction) */ 00019 float exposure; /* a value of 1.0 in an image corresponds to 00020 * <exposure> watts/steradian/m^2. 00021 * defaults to 1.0 */ 00022 } rgbe_header_info; 00023 00024 /* flags indicating which fields in an rgbe_header_info are valid */ 00025 #define RGBE_VALID_PROGRAMTYPE 0x01 00026 #define RGBE_VALID_GAMMA 0x02 00027 #define RGBE_VALID_EXPOSURE 0x04 00028 00029 /* return codes for rgbe routines */ 00030 #define RGBE_RETURN_SUCCESS 0 00031 #define RGBE_RETURN_FAILURE -1 00032 00033 /* read or write headers */ 00034 /* you may set rgbe_header_info to null if you want to */ 00035 int RGBE_WriteHeader(FILE *fp, const int width, const int height, const rgbe_header_info *info); 00036 int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info); 00037 00038 /* read or write pixels */ 00039 /* can read or write pixels in chunks of any size including single pixels*/ 00040 int RGBE_WritePixels(FILE *fp, const float *data, const int numpixels); 00041 int RGBE_ReadPixels(FILE *fp, float *data, const int numpixels); 00042 00043 /* read or write run length encoded files */ 00044 /* must be called to read or write whole scanlines */ 00045 int RGBE_WritePixels_RLE(FILE *fp, const float *data, const int scanline_width, const int num_scanlines); 00046 int RGBE_ReadPixels_RLE(FILE *fp, float *data, const int scanline_width, const int num_scanlines); 00047 00048 #endif /* _H_RGBE */ 00049 00050 00051