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.1 by greg, Fri Mar 26 03:11:50 2004 UTC vs.
Revision 2.6 by greg, Sat May 31 19:38:36 2008 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 26 | Line 26 | typedef struct {
26  
27   /* Allocated BMP header data */
28   typedef struct {
29 <        /* the following fields may be altered before open call */
29 >        /* the following fields may be altered before the open call */
30          int             yIsDown;        /* scanlines proceed downward? */
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 */
35 <        /* the following fields should not be altered after allocation */
35 >        int             compr;          /* compression */
36          int32           width;          /* bitmap width (pixels) */
37          int32           height;         /* bitmap height (pixels) */
38 +        /* the following fields must not be altered after allocation */
39          int             bpp;            /* bits per sample (1,4,8,16,24,32) */
39        int             compr;          /* compression */
40          uint32          infoSiz;        /* info buffer size (bytes) */
41 <        /* the color table should be filled by writer before open call */
42 <        RGBquad         palette[2];     /* color palette (extends struct) */
41 >        /* but the color table should be filled by writer before open call */
42 >        RGBquad         palette[3];     /* color palette (extends struct) */
43   } BMPHeader;
44 +                                
45 +                                        /* access to bit field triple */
46 + #define BMPbitField(h)  ((uint32 *)(h)->palette)
47  
45                                        /* color palette length */
46 #define BMPpalLen(h)    ((h)->bpp <= 8 ? 1<<(h)->bpp : 0)
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 */
53   #define BIR_EOF                 (-1)            /* reached end of file */
54   #define BIR_TRUNCATED           1               /* unexpected EOF */
55   #define BIR_UNSUPPORTED         2               /* unsupported encoding */
56 < #define BIR_SEEKERR             3               /* could not seek */
56 > #define BIR_RLERROR             3               /* RLE error */
57 > #define BIR_SEEKERR             4               /* could not seek */
58  
59   /* A BMP reader structure */
60   typedef struct BMPReader {
# Line 74 | Line 75 | typedef struct BMPReader {
75   typedef struct {
76          /* the scanline data is filled in by caller before each write */
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 by the caller */
80 >        /* the following fields should not be altered directly */
81          BMPHeader       *hdr;           /* allocated header */
82          uint32          fbmp;           /* beginning of bitmap data */
83          uint32          fpos;           /* current file position */
# Line 101 | Line 103 | int            BMPreadScanline(BMPReader *br);
103   int             BMPseekScanline(int y, BMPReader *br);
104  
105                                          /* get ith pixel from last scanline */
106 < RGBquad         BMPdecodePixel(int i, BMPReader *br);
106 > RGBquad         BMPdecodePixel(int i, const BMPReader *br);
107  
108                                          /* free BMP reader resources */
109   void            BMPfreeReader(BMPReader *br);
# Line 136 | Line 138 | int            stdio_fseek(uint32 pos, void *p);
138  
139                                          /* open input file */
140   #define BMPopenInputFile(fn)    BMPopenReader(&stdio_getc, &stdio_fseek, \
141 <                                        (void *)fopen(fn, "r"))
141 >                                        (void *)fopen(fn, "rb"))
142  
143                                          /* close stdio input file or stream */
144   #define BMPcloseInput(br)       ( fclose((FILE *)(br)->c_data), \
# Line 149 | 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), \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines