--- ray/src/common/bmpfile.h 2004/03/26 03:11:50 2.1 +++ ray/src/common/bmpfile.h 2004/03/27 05:43:37 2.3 @@ -1,4 +1,4 @@ -/* RCSid $Id: bmpfile.h,v 2.1 2004/03/26 03:11:50 greg Exp $ */ +/* RCSid $Id: bmpfile.h,v 2.3 2004/03/27 05:43:37 greg Exp $ */ /* * Windows and OS/2 BMP file support */ @@ -26,24 +26,27 @@ typedef struct { /* Allocated BMP header data */ typedef struct { - /* the following fields may be altered before open call */ + /* the following fields may be altered before the open call */ int yIsDown; /* scanlines proceed downward? */ int32 hRes; /* horizontal resolution pixels/meter */ int32 vRes; /* vertical resolution pixels/meter */ int nColors; /* total color palette size */ int impColors; /* number of colors actually used */ - /* the following fields should not be altered after allocation */ + int compr; /* compression */ int32 width; /* bitmap width (pixels) */ int32 height; /* bitmap height (pixels) */ + /* the following fields must not be altered after allocation */ int bpp; /* bits per sample (1,4,8,16,24,32) */ - int compr; /* compression */ uint32 infoSiz; /* info buffer size (bytes) */ - /* the color table should be filled by writer before open call */ - RGBquad palette[2]; /* color palette (extends struct) */ + /* but the color table should be filled by writer before open call */ + RGBquad palette[3]; /* color palette (extends struct) */ } BMPHeader; /* color palette length */ #define BMPpalLen(h) ((h)->bpp <= 8 ? 1<<(h)->bpp : 0) + + /* access to bit field triple */ +#define BMPbitField(h) ((uint32 *)(h)->palette) /* info buffer access */ #define BMPinfo(h) ((char *)((h)->palette + BMPpalLen(h))) @@ -53,7 +56,8 @@ typedef struct { #define BIR_EOF (-1) /* reached end of file */ #define BIR_TRUNCATED 1 /* unexpected EOF */ #define BIR_UNSUPPORTED 2 /* unsupported encoding */ -#define BIR_SEEKERR 3 /* could not seek */ +#define BIR_RLERROR 3 /* RLE error */ +#define BIR_SEEKERR 4 /* could not seek */ /* A BMP reader structure */ typedef struct BMPReader { @@ -74,8 +78,9 @@ typedef struct BMPReader { typedef struct { /* the scanline data is filled in by caller before each write */ uint8 *scanline; /* caller-prepared scanline data */ + /* modify yscan only if seek is defined & data is uncompressed */ int yscan; /* scanline for next write */ - /* the following fields should not be altered by the caller */ + /* the following fields should not be altered directly */ BMPHeader *hdr; /* allocated header */ uint32 fbmp; /* beginning of bitmap data */ uint32 fpos; /* current file position */ @@ -101,7 +106,7 @@ int BMPreadScanline(BMPReader *br); int BMPseekScanline(int y, BMPReader *br); /* get ith pixel from last scanline */ -RGBquad BMPdecodePixel(int i, BMPReader *br); +RGBquad BMPdecodePixel(int i, const BMPReader *br); /* free BMP reader resources */ void BMPfreeReader(BMPReader *br);