rgbe.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @file   rgbe.h
00003    @author Bruce Walter (http://www.graphics.cornell.edu/~bjw/)
00004    @author Travis Fischer (fisch0920@gmail.com)
00005    @date   January 2009
00006    
00007    @brief
00008       Utilities for reading and writing Ward's rgbe image format.
00009    
00010    @note
00011       This code is from http://www.graphics.cornell.edu/~bjw/rgbe/
00012    
00013    @ee also http://www.graphics.cornell.edu/online/formats/rgbe/
00014    <!-------------------------------------------------------------------->**/
00015 
00016 #ifndef RGBE_H_
00017 #define RGBE_H_
00018 
00019 /* THIS CODE CARRIES NO GUARANTEE OF USABILITY OR FITNESS FOR ANY PURPOSE.
00020  * WHILE THE AUTHORS HAVE TRIED TO ENSURE THE PROGRAM WORKS CORRECTLY,
00021  * IT IS STRICTLY USE AT YOUR OWN RISK. */
00022 
00023 #include <stdio.h>
00024 
00025 typedef struct {
00026   int valid;            /* indicate which fields are valid */
00027   char programtype[16]; /* listed at beginning of file to identify it 
00028                          * after "#?".  defaults to "RGBE" */ 
00029   float gamma;          /* image has already been gamma corrected with 
00030                          * given gamma.  defaults to 1.0 (no correction) */
00031   float exposure;       /* a value of 1.0 in an image corresponds to
00032                          * <exposure> watts/steradian/m^2. 
00033                          * defaults to 1.0 */
00034 } rgbe_header_info;
00035 
00036 /* flags indicating which fields in an rgbe_header_info are valid */
00037 #define RGBE_VALID_PROGRAMTYPE 0x01
00038 #define RGBE_VALID_GAMMA       0x02
00039 #define RGBE_VALID_EXPOSURE    0x04
00040 
00041 /* return codes for rgbe routines */
00042 #define RGBE_RETURN_SUCCESS 0
00043 #define RGBE_RETURN_FAILURE -1
00044 
00045 /**
00046  * @brief
00047  *    writes headers
00048  * 
00049  * @note
00050  *    you may set rgbe_header_info to null if you want to
00051  */
00052 int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info);
00053 
00054 /**
00055  * @brief
00056  *    reads headers
00057  * 
00058  * @note
00059  *    you may set rgbe_header_info to null if you want to
00060  */
00061 int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info);
00062 
00063 
00064 /** 
00065  * @brief
00066  *    writes pixels
00067  * 
00068  * @note
00069  *    can write pixels in chunks of any size including single pixels
00070  */
00071 int RGBE_WritePixels(FILE *fp, const float *data, int numpixels);
00072 
00073 /** 
00074  * @brief
00075  *    reads pixels
00076  * 
00077  * @note
00078  *    can read pixels in chunks of any size including single pixels
00079  */
00080 int RGBE_ReadPixels(FILE *fp, float *data, int numpixels);
00081 
00082 
00083 /** 
00084  * @brief
00085  *    writes run length encoded files
00086  * 
00087  * @note
00088  *    must be called to write whole scanlines
00089  */
00090 int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
00091                          int num_scanlines);
00092 
00093 /** 
00094  * @brief
00095  *    reads run length encoded files
00096  * 
00097  * @note
00098  *    must be called to read whole scanlines
00099  */
00100 int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
00101                         int num_scanlines);
00102 
00103 #endif /* RGBE_H_ */
00104 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6