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);
40 static char er_internal[] =
"%s: internal error!";
43 BMPlenfileheader(
int classv)
56 pm_error(er_internal,
"BMPlenfileheader");
62 BMPleninfoheader(
int classv)
79 pm_error(er_internal,
"BMPleninfoheader");
85 BMPlenrgbtable(
int classv,
unsigned long bitcount)
95 pm_error(er_internal,
"BMPlenrgbtable");
107 pm_error(er_internal,
"BMPlenrgbtable");
111 return (1 << bitcount) * lenrgb;
122 BMPlenline(
int classv,
unsigned long bitcount,
unsigned long x)
124 unsigned long bitsperline;
126 bitsperline = x * bitcount;
132 if ((bitsperline % 32) != 0)
134 bitsperline += (32 - (bitsperline % 32));
137 if ((bitsperline % 32) != 0)
139 pm_error(er_internal,
"BMPlenline");
144 return bitsperline >> 3;
151 unsigned long bitcount,
155 return y * BMPlenline(classv, bitcount, x);
162 unsigned long bitcount)
164 return BMPlenfileheader(classv)
165 + BMPleninfoheader(classv)
166 + BMPlenrgbtable(classv, bitcount);
173 unsigned long bitcount,
177 return BMPoffbits(classv, bitcount)
178 + BMPlenbits(classv, bitcount, x, y);