2
0

rgbe.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /* utility for reading and writing Ward's rgbe image format.
  7. See rgbe.txt file for more details.
  8. */
  9. #include <stdio.h>
  10. typedef struct {
  11. int valid; /* indicate which fields are valid */
  12. char programtype[16]; /* listed at beginning of file to identify it
  13. * after "#?". defaults to "RGBE" */
  14. float gamma; /* image has already been gamma corrected with
  15. * given gamma. defaults to 1.0 (no correction) */
  16. float exposure; /* a value of 1.0 in an image corresponds to
  17. * <exposure> watts/steradian/m^2.
  18. * defaults to 1.0 */
  19. } rgbe_header_info;
  20. /* flags indicating which fields in an rgbe_header_info are valid */
  21. #define RGBE_VALID_PROGRAMTYPE 0x01
  22. #define RGBE_VALID_GAMMA 0x02
  23. #define RGBE_VALID_EXPOSURE 0x04
  24. /* return codes for rgbe routines */
  25. #define RGBE_RETURN_SUCCESS 0
  26. #define RGBE_RETURN_FAILURE -1
  27. /* read or write headers */
  28. /* you may set rgbe_header_info to null if you want to */
  29. int RGBE_WriteHeader(FILE *fp, int width, int height, rgbe_header_info *info);
  30. int RGBE_ReadHeader(FILE *fp, int *width, int *height, rgbe_header_info *info);
  31. /* read or write pixels */
  32. /* can read or write pixels in chunks of any size including single pixels*/
  33. int RGBE_WritePixels(FILE *fp, float *data, int numpixels);
  34. int RGBE_ReadPixels(FILE *fp, float *data, int numpixels);
  35. /* read or write run length encoded files */
  36. /* must be called to read or write whole scanlines */
  37. int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
  38. int num_scanlines);
  39. int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
  40. int num_scanlines);
  41. #endif /* _H_RGBE */