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