ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/bmpfile.h
(Generate patch)

Comparing ray/src/common/bmpfile.h (file contents):
Revision 2.3 by greg, Sat Mar 27 05:43:37 2004 UTC vs.
Revision 2.8 by greg, Tue Sep 5 18:41:22 2017 UTC

# Line 6 | Line 6
6   #ifndef _RAD_BMPFILE_H_
7   #define _RAD_BMPFILE_H_
8  
9 < #include "tifftypes.h"
9 > #include "tiff.h"                       /* needed for int32, etc. */
10  
11   #ifdef __cplusplus
12   extern "C" {
# Line 31 | Line 31 | typedef struct {
31          int32           hRes;           /* horizontal resolution pixels/meter */
32          int32           vRes;           /* vertical resolution pixels/meter */
33          int             nColors;        /* total color palette size */
34 <        int             impColors;      /* number of colors actually used */
34 >        int             impColors;      /* number of colors actually used */
35          int             compr;          /* compression */
36          int32           width;          /* bitmap width (pixels) */
37          int32           height;         /* bitmap height (pixels) */
# Line 39 | Line 39 | typedef struct {
39          int             bpp;            /* bits per sample (1,4,8,16,24,32) */
40          uint32          infoSiz;        /* info buffer size (bytes) */
41          /* but the color table should be filled by writer before open call */
42 <        RGBquad         palette[3];     /* color palette (extends struct) */
42 >        RGBquad         palette[3];     /* color palette (extends struct) */
43   } BMPHeader;
44
45                                        /* color palette length */
46 #define BMPpalLen(h)    ((h)->bpp <= 8 ? 1<<(h)->bpp : 0)
44                                  
45                                          /* access to bit field triple */
46 < #define BMPbitField(h)  ((uint32 *)(h)->palette)
46 > #define BMPbitField(h)  ((uint32 *)(h)->palette)
47  
48                                          /* info buffer access */
49 < #define BMPinfo(h)      ((char *)((h)->palette + BMPpalLen(h)))
49 > #define BMPinfo(h)      ((char *)((h)->palette + (h)->nColors))
50  
51                                          /* function return values */
52   #define BIR_OK                  0               /* all is well */
# Line 62 | Line 59 | typedef struct {
59   /* A BMP reader structure */
60   typedef struct BMPReader {
61          /* members in this structure should be considered read-only */
62 <        uint8           *scanline;      /* unpacked scanline data */
62 >        uint8           *scanline;      /* unpacked scanline data */
63          int             yscan;          /* last scanline read */
64 <        BMPHeader       *hdr;           /* pointer to allocated header */
64 >        BMPHeader       *hdr;           /* pointer to allocated header */
65          uint32          fpos;           /* current file position */
66                                          /* get character callback */
67          int             (*cget)(void *);
68                                          /* absolute seek callback (or NULL) */
69          int             (*seek)(uint32, void *);
70          void            *c_data;        /* client's opaque data */
71 <        uint32          scanpos[1];     /* recorded scanline position(s) */
71 >        uint32          scanpos[1];     /* recorded scanline position(s) */
72   } BMPReader;
73  
74   /* A BMP writer structure */
75   typedef struct {
76          /* the scanline data is filled in by caller before each write */
77 <        uint8           *scanline;      /* caller-prepared scanline data */
77 >        uint8           *scanline;      /* caller-prepared scanline data */
78          /* modify yscan only if seek is defined & data is uncompressed */
79          int             yscan;          /* scanline for next write */
80          /* the following fields should not be altered directly */
81 <        BMPHeader       *hdr;           /* allocated header */
81 >        BMPHeader       *hdr;           /* allocated header */
82          uint32          fbmp;           /* beginning of bitmap data */
83          uint32          fpos;           /* current file position */
84          uint32          flen;           /* last character written */
# Line 93 | Line 90 | typedef struct {
90   } BMPWriter;
91  
92                                          /* open BMP stream for reading */
93 < BMPReader       *BMPopenReader(int (*cget)(void *),
93 > extern BMPReader        *BMPopenReader(int (*cget)(void *),
94                                  int (*seek)(uint32, void *), void *c_data);
95  
96                                          /* determine if image is grayscale */
97 < int             BMPisGrayscale(const BMPHeader *hdr);
97 > extern int              BMPisGrayscale(const BMPHeader *hdr);
98  
99                                          /* read next BMP scanline */
100 < int             BMPreadScanline(BMPReader *br);
100 > extern int              BMPreadScanline(BMPReader *br);
101  
102                                          /* read a specific scanline */
103 < int             BMPseekScanline(int y, BMPReader *br);
103 > extern int              BMPseekScanline(int y, BMPReader *br);
104  
105                                          /* get ith pixel from last scanline */
106 < RGBquad         BMPdecodePixel(int i, const BMPReader *br);
106 > extern RGBquad          BMPdecodePixel(int i, const BMPReader *br);
107  
108                                          /* free BMP reader resources */
109 < void            BMPfreeReader(BMPReader *br);
109 > extern void             BMPfreeReader(BMPReader *br);
110  
111                                          /* allocate uncompressed RGB header */
112 < BMPHeader       *BMPtruecolorHeader(int xr, int yr, int infolen);
112 > extern BMPHeader        *BMPtruecolorHeader(int xr, int yr, int infolen);
113  
114                                          /* allocate color-mapped header */
115 < BMPHeader       *BMPmappedHeader(int xr, int yr, int infolen, int ncolors);
115 > extern BMPHeader        *BMPmappedHeader(int xr, int yr, int infolen, int ncolors);
116  
117                                          /* open BMP stream for writing */
118 < BMPWriter       *BMPopenWriter(void (*cput)(int, void *),
118 > extern BMPWriter        *BMPopenWriter(void (*cput)(int, void *),
119                                  int (*seek)(uint32, void *), void *c_data,
120                                          BMPHeader *hdr);
121                                  
122                                          /* write the prepared scanline */
123 < int             BMPwriteScanline(BMPWriter *bw);
123 > extern int              BMPwriteScanline(BMPWriter *bw);
124  
125                                          /* free BMP writer resources */
126 < void            BMPfreeWriter(BMPWriter *bw);
126 > extern void             BMPfreeWriter(BMPWriter *bw);
127  
128                                          /* get corresponding error message */
129 < const char      *BMPerrorMessage(int ec);
129 > extern const char       *BMPerrorMessage(int ec);
130  
131                                          /* stdio callback functions */
132 < int             stdio_getc(void *p);
133 < void            stdio_putc(int c, void *p);
134 < int             stdio_fseek(uint32 pos, void *p);
132 > extern int              stdio_getc(void *p);
133 > extern void             stdio_putc(int c, void *p);
134 > extern int              stdio_fseek(uint32 pos, void *p);
135  
136                                          /* open stdio input stream */
137 < #define BMPopenInputStream(fp)  BMPopenReader(&stdio_getc, NULL, (void *)fp)
137 > #define BMPopenInputStream(fp)  BMPopenReader(&stdio_getc, NULL, (void *)fp)
138  
139                                          /* open input file */
140 < #define BMPopenInputFile(fn)    BMPopenReader(&stdio_getc, &stdio_fseek, \
141 <                                        (void *)fopen(fn, "r"))
140 > #define BMPopenInputFile(fn)    BMPopenReader(&stdio_getc, &stdio_fseek, \
141 >                                        (void *)fopen(fn, "rb"))
142  
143                                          /* close stdio input file or stream */
144 < #define BMPcloseInput(br)       ( fclose((FILE *)(br)->c_data), \
144 > #define BMPcloseInput(br)       ( fclose((FILE *)(br)->c_data), \
145                                          BMPfreeReader(br) )
146  
147                                          /* open stdio output stream */
# Line 154 | Line 151 | int            stdio_fseek(uint32 pos, void *p);
151                                          /* open stdio output file */
152   #define BMPopenOutputFile(fn,hdr) \
153                          BMPopenWriter(&stdio_putc, &stdio_fseek, \
154 <                                        (void *)fopen(fn, "w"), hdr)
154 >                                        (void *)fopen(fn, "wb"), hdr)
155  
156                                          /* close stdio output file or stream */
157 < #define BMPcloseOutput(bw)      ( fclose((FILE *)(bw)->c_data), \
157 > #define BMPcloseOutput(bw)      ( fclose((FILE *)(bw)->c_data), \
158                                          BMPfreeWriter(bw) )
159  
160   #ifdef __cplusplus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines