| 522 |
|
return hdr; |
| 523 |
|
} |
| 524 |
|
|
| 525 |
< |
/* allocate color-mapped header (defaults minimal grayscale) */ |
| 525 |
> |
/* allocate color-mapped header (defaults to minimal grayscale) */ |
| 526 |
|
BMPHeader * |
| 527 |
|
BMPmappedHeader(int xr, int yr, int infolen, int ncolors) |
| 528 |
|
{ |
| 549 |
|
hdr->height = yr; |
| 550 |
|
hdr->yIsDown = 0; /* default to upwards order */ |
| 551 |
|
hdr->bpp = n; |
| 552 |
< |
hdr->compr = BI_UNCOMPR; |
| 552 |
> |
hdr->compr = BI_UNCOMPR; /* compression needs seek */ |
| 553 |
|
hdr->hRes = hdr->vRes = 2835; /* default to 72 ppi */ |
| 554 |
|
hdr->nColors = ncolors; |
| 555 |
|
hdr->impColors = 0; /* says all colors important */ |
| 628 |
|
return NULL; |
| 629 |
|
if ((hdr->bpp == 16) | (hdr->compr == BI_RLE4)) |
| 630 |
|
return NULL; /* unsupported */ |
| 631 |
+ |
/* no seek means we may have the wrong file length, but most app's don't care |
| 632 |
|
if (seek == NULL && ((hdr->compr == BI_RLE8) | (hdr->compr == BI_RLE4))) |
| 633 |
|
return NULL; |
| 634 |
+ |
*/ |
| 635 |
|
/* compute sizes */ |
| 636 |
|
hdrSiz = 2 + 6*4 + 2*2 + 6*4; |
| 637 |
|
if (hdr->compr == BI_BITFIELDS) |
| 698 |
|
continue; |
| 699 |
|
cnt = 1; /* else let's try it */ |
| 700 |
|
while (bp[cnt] == bp[0]) |
| 701 |
< |
if (++cnt >= 5) /* long enough */ |
| 702 |
< |
return pos; |
| 701 |
> |
if (++cnt >= 5) |
| 702 |
> |
return pos; /* long enough */ |
| 703 |
|
} |
| 704 |
|
return pos; /* didn't find any */ |
| 705 |
|
} |
| 751 |
|
if (n <= 0) /* was that it? */ |
| 752 |
|
break; |
| 753 |
|
val = *sp; /* output run */ |
| 754 |
< |
for (cnt = 1; (--n > 0) & (*++sp == val); cnt++) |
| 755 |
< |
; |
| 754 |
> |
for (cnt = 1; cnt < 255; cnt++) |
| 755 |
> |
if (!--n | *++sp != val) |
| 756 |
> |
break; |
| 757 |
|
wrbyte(cnt, bw); |
| 758 |
|
wrbyte(val, bw); |
| 759 |
|
} |
| 760 |
< |
bw->yscan++; /* write file length at end */ |
| 760 |
> |
bw->yscan++; /* write line break or EOD */ |
| 761 |
|
if (bw->yscan == bw->hdr->height) { |
| 762 |
|
wrbyte(0, bw); wrbyte(1, bw); /* end of bitmap marker */ |
| 763 |
|
if (bw->seek == NULL || (*bw->seek)(2, bw->c_data) != 0) |
| 764 |
< |
return BIR_SEEKERR; |
| 764 |
> |
return BIR_OK; /* no one may care */ |
| 765 |
|
bw->fpos = 2; |
| 766 |
< |
wrint32(bw->flen, bw); /* corrected file length */ |
| 766 |
> |
wrint32(bw->flen-bw->fbmp, bw); /* output correct bitmap length */ |
| 767 |
|
} else { |
| 768 |
|
wrbyte(0, bw); wrbyte(0, bw); /* end of line marker */ |
| 769 |
|
} |