18 #include "pandabase.h"
19 #include "pnmimage_base.h"
22 static unsigned long BMPlenfileheader(
int classv);
23 static unsigned long BMPleninfoheader(
int classv);
24 static unsigned long BMPlenrgbtable(
int classv,
unsigned long bitcount);
25 static unsigned long BMPlenline(
int classv,
unsigned long bitcount,
unsigned long x);
26 static unsigned long BMPlenbits(
int classv,
unsigned long bitcount,
unsigned long x,
unsigned long y);
27 static unsigned long BMPlenfile(
int classv,
unsigned long bitcount,
unsigned long x,
unsigned long y);
28 static unsigned long BMPoffbits(
int classv,
unsigned long bitcount);
36 static char er_internal[] =
"%s: internal error!";
39 BMPlenfileheader(
int classv)
48 pm_error(er_internal,
"BMPlenfileheader");
54 BMPleninfoheader(
int classv)
63 pm_error(er_internal,
"BMPleninfoheader");
69 BMPlenrgbtable(
int classv,
unsigned long bitcount)
79 pm_error(er_internal,
"BMPlenrgbtable");
91 pm_error(er_internal,
"BMPlenrgbtable");
95 return (1 << bitcount) * lenrgb;
106 BMPlenline(
int classv,
unsigned long bitcount,
unsigned long x)
108 unsigned long bitsperline;
117 pm_error(er_internal,
"BMPlenline");
121 bitsperline = x * bitcount;
127 if ((bitsperline % 32) != 0)
129 bitsperline += (32 - (bitsperline % 32));
132 if ((bitsperline % 32) != 0)
134 pm_error(er_internal,
"BMPlenline");
139 return bitsperline >> 3;
146 unsigned long bitcount,
150 return y * BMPlenline(classv, bitcount, x);
157 unsigned long bitcount)
159 return BMPlenfileheader(classv)
160 + BMPleninfoheader(classv)
161 + BMPlenrgbtable(classv, bitcount);
168 unsigned long bitcount,
172 return BMPoffbits(classv, bitcount)
173 + BMPlenbits(classv, bitcount, x, y);