| 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" { |
| 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 */ |
| 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 |
– |
/* 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) |
| 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 */ |
| 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 */ |
| 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), \ |
| 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), \ |