ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/bmpfile.c
(Generate patch)

Comparing ray/src/common/bmpfile.c (file contents):
Revision 2.2 by schorsch, Fri Mar 26 21:29:19 2004 UTC vs.
Revision 2.9 by greg, Thu Apr 29 14:36:49 2004 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   *  Windows and OS/2 BMP file support
6   */
7  
8 /* XXX reading and writing of compressed files currently unsupported */
9
8   #include <stdio.h>
9   #include <stdlib.h>
10   #include <string.h>
11   #include "bmpfile.h"
12  
13 + #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
14 + #define getc    getc_unlocked
15 + #define putc    putc_unlocked
16 + #endif
17 +
18   /* get corresponding error message */
19   const char *
20   BMPerrorMessage(int ec)
# Line 25 | Line 28 | BMPerrorMessage(int ec)
28                  return "Truncated BMP image";
29          case BIR_UNSUPPORTED:
30                  return "Unsupported BMP feature";
31 +        case BIR_RLERROR:
32 +                return "BMP runlength encoding error";
33          case BIR_SEEKERR:
34                  return "BMP seek error";
35          }
36          return "Unknown BMP error";
37   }
38  
39 < /* compute uncompressed scanline size */
40 < static uint32
41 < getScanSiz(BMPHeader *hdr)
39 > /* check than header is sensible */
40 > static int
41 > BMPheaderOK(const BMPHeader *hdr)
42   {
43 <        uint32  scanSiz;
44 <                                                /* bytes per scanline */
45 <        scanSiz = (hdr->bpp*hdr->width + 7) >> 3;
46 <        if (scanSiz & 3)                        /* 32-bit word boundary */
47 <                scanSiz += 4 - (scanSiz & 3);
48 <
49 <        return scanSiz;
43 >        if (!hdr)
44 >                return 0;
45 >        if ((hdr->width <= 0) | (hdr->height <= 0))
46 >                return 0;
47 >        switch (hdr->bpp) {             /* check compression */
48 >        case 1:
49 >        case 24:
50 >                if (hdr->compr != BI_UNCOMPR)
51 >                        return 0;
52 >                break;
53 >        case 16:
54 >        case 32:
55 >                if ((hdr->compr != BI_UNCOMPR) & (hdr->compr != BI_BITFIELDS))
56 >                        return 0;
57 >                break;
58 >        case 4:
59 >                if ((hdr->compr != BI_UNCOMPR) & (hdr->compr != BI_RLE4))
60 >                        return 0;
61 >                break;
62 >        case 8:
63 >                if ((hdr->compr != BI_UNCOMPR) & (hdr->compr != BI_RLE8))
64 >                        return 0;
65 >                break;
66 >        default:
67 >                return 0;
68 >        }
69 >        if (hdr->compr == BI_BITFIELDS && (BMPbitField(hdr)[0] &
70 >                                BMPbitField(hdr)[1] & BMPbitField(hdr)[2]))
71 >                return 0;
72 >        if ((hdr->nColors < 0) | (hdr->impColors < 0))
73 >                return 0;
74 >        if (hdr->impColors > hdr->nColors)
75 >                return 0;
76 >        if (hdr->nColors > BMPpalLen(hdr))
77 >                return 0;
78 >        return 1;
79   }
80  
81 +                                        /* compute uncompressed scan size */
82 + #define getScanSiz(h)   ( ((((h)->bpp*(h)->width+7) >>3) + 3) & ~03 )
83 +
84                                          /* get next byte from reader */
85   #define rdbyte(c,br)    ((br)->fpos += (c=(*(br)->cget)((br)->c_data))!=EOF, c)
86  
# Line 130 | Line 167 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
167          (void)rdint32(br);                      /* file size */
168          (void)rdint32(br);                      /* reserved word */
169          bmPos = rdint32(br);                    /* offset to bitmap */
170 <        hdrSiz = rdint32(br) + 14;              /* header size */
170 >        hdrSiz = 2 + 3*4 + rdint32(br);         /* header size */
171          if (hdrSiz < 2 + 6*4 + 2*2 + 6*4)
172                  goto err;
173          br->hdr->width = rdint32(br);           /* bitmap width */
# Line 142 | Line 179 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
179          if (rduint16(br) != 1)                  /* number of planes */
180                  goto err;
181          br->hdr->bpp = rduint16(br);            /* bits per pixel */
145        if (br->hdr->bpp != 1 && br->hdr->bpp != 4 &&
146                        br->hdr->bpp != 8 && br->hdr->bpp != 24 &&
147                        br->hdr->bpp != 32)
148                goto err;
182          br->hdr->compr = rdint32(br);           /* compression mode */
150        if (br->hdr->compr != BI_UNCOMPR && br->hdr->compr != BI_RLE8)
151                goto err;                       /* don't support the rest */
183          (void)rdint32(br);                      /* bitmap size */
184          br->hdr->hRes = rdint32(br);            /* horizontal resolution */
185          br->hdr->vRes = rdint32(br);            /* vertical resolution */
# Line 156 | Line 187 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
187          br->hdr->impColors = rdint32(br);       /* # important colors */
188          if (br->hdr->impColors < 0)
189                  goto err;                       /* catch premature EOF */
190 <        palLen = 0;
191 <        if (br->hdr->bpp <= 8) {
192 <                palLen = 1 << br->hdr->bpp;
190 >        if (!BMPheaderOK(br->hdr))
191 >                goto err;
192 >        palLen = BMPpalLen(br->hdr);
193 >        if (br->hdr->bpp <= 8) {                /* normalize color counts */
194                  if (br->hdr->nColors <= 0)
195                          br->hdr->nColors = palLen;
164                else if (br->hdr->nColors > palLen)
165                        goto err;
196                  if (br->hdr->impColors <= 0)
197                          br->hdr->impColors = br->hdr->nColors;
198 <                else if (br->hdr->impColors > br->hdr->nColors)
169 <                        goto err;
170 <        } else if (br->hdr->nColors > 0 || br->hdr->compr != BI_UNCOMPR)
171 <                goto err;
198 >        }
199                                                  /* extend header */
200          if (bmPos < hdrSiz + sizeof(RGBquad)*palLen)
201                  goto err;
# Line 176 | Line 203 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
203          if (palLen > 0 || br->hdr->infoSiz > 0) {
204                  br->hdr = (BMPHeader *)realloc((void *)br->hdr,
205                                          sizeof(BMPHeader) +
206 <                                        sizeof(RGBquad)*palLen -
180 <                                        sizeof(br->hdr->palette) +
206 >                                        sizeof(RGBquad)*palLen +
207                                          br->hdr->infoSiz);
208                  if (br->hdr == NULL)
209                          goto err;
210          }
211 <                                                /* read color palette */
212 <        if (rdbytes((char *)br->hdr->palette,
211 >                                                /* read colors or fields */
212 >        if (br->hdr->compr == BI_BITFIELDS) {
213 >                BMPbitField(br->hdr)[0] = (uint32)rdint32(br);
214 >                BMPbitField(br->hdr)[1] = (uint32)rdint32(br);
215 >                BMPbitField(br->hdr)[2] = (uint32)rdint32(br);
216 >        } else if (rdbytes((char *)br->hdr->palette,
217                          sizeof(RGBquad)*palLen, br) != BIR_OK)
218                  goto err;
219                                                  /* read add'l information */
# Line 194 | Line 224 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
224          if (br->scanline == NULL)
225                  goto err;
226          br->yscan = -1;
227 <        if (seek != NULL && br->hdr->compr != BI_UNCOMPR) {
227 >        if (seek != NULL && ((br->hdr->compr == BI_RLE8) |
228 >                                        (br->hdr->compr == BI_RLE4))) {
229                  BMPReader       *newbr = (BMPReader *)realloc((void *)br,
230                                                  sizeof(BMPReader) +
231                                                  sizeof(br->scanpos[0]) *
# Line 229 | Line 260 | BMPisGrayscale(const BMPHeader *hdr)
260                  return -1;
261          if (hdr->bpp > 8)               /* assume they had a reason for it */
262                  return 0;
263 <        for (rgbp = hdr->palette, n = hdr->impColors; n-- > 0; rgbp++)
263 >        for (rgbp = hdr->palette, n = hdr->nColors; n-- > 0; rgbp++)
264                  if (((rgbp->r != rgbp->g) | (rgbp->g != rgbp->b)))
265                          return 0;
266          return 1;                       /* all colors neutral in map */
# Line 239 | Line 270 | BMPisGrayscale(const BMPHeader *hdr)
270   int
271   BMPreadScanline(BMPReader *br)
272   {
273 +        int     n;
274 +        int8    *sp;
275 +
276          if (br->yscan + 1 >= br->hdr->height)
277                  return BIR_EOF;
278          br->yscan++;                    /* prepare to read */
279 <        if (br->hdr->compr == BI_UNCOMPR)
280 <                return rdbytes((char *)br->scanline, getScanSiz(br->hdr), br);
281 < /* XXX need to perform actual decompression */
282 <        return BIR_UNSUPPORTED;
283 <        if (br->seek != NULL)
279 >        n = getScanSiz(br->hdr);        /* reading uncompressed data? */
280 >        if (br->hdr->compr == BI_UNCOMPR || br->hdr->compr == BI_BITFIELDS)
281 >                return rdbytes((char *)br->scanline, n, br);
282 >        /*
283 >         * RLE/RLE8 Decoding
284 >         *
285 >         * Certain aspects of this scheme are completely insane, so
286 >         * we don't support them.  Fortunately, they rarely appear.
287 >         * One is the mid-file EOD (0x0001) and another is the ill-conceived
288 >         * "delta" (0x0002), which is like a "goto" statement for bitmaps.
289 >         * Whoever thought this up should be shot, then told why
290 >         * it's impossible to support such a scheme in any reasonable way.
291 >         * Also, RLE4 mode allows runs to stop halfway through a byte,
292 >         * which is likewise uncodeable, so we don't even try.
293 >         * Finally, the scanline break is ambiguous -- we assume here that
294 >         * it is required at the end of each scanline, though I haven't
295 >         * found anywhere this is written.  Otherwise, we would read to
296 >         * the end of the scanline, assuming the next bit of data belongs
297 >         * the following scan.  If a break follows the last pixel, as it
298 >         * seems to in the files I've tested out of Photoshop, you end up
299 >         * painting every other line black.  Also, I assume any skipped
300 >         * pixels are painted with color 0, which is often black.  Nowhere
301 >         * is it specified what we should assume for missing pixels.  This
302 >         * is undoubtedly the most brain-dead format I've ever encountered.
303 >         */
304 >        sp = br->scanline;
305 >        while (n > 0) {
306 >                int     skipOdd, len, val;
307 >
308 >                if (rdbyte(len, br) == EOF)
309 >                        return BIR_TRUNCATED;
310 >                if (len > 0) {          /* got a run */
311 >                        if (br->hdr->compr == BI_RLE4) {
312 >                                if (len & 1)
313 >                                        return BIR_UNSUPPORTED;
314 >                                len >>= 1;
315 >                        }
316 >                        if (len > n)
317 >                                return BIR_RLERROR;
318 >                        if (rdbyte(val, br) == EOF)
319 >                                return BIR_TRUNCATED;
320 >                        n -= len;
321 >                        while (len--)
322 >                                *sp++ = val;
323 >                        continue;
324 >                }
325 >                switch (rdbyte(len, br)) {
326 >                case EOF:
327 >                        return BIR_TRUNCATED;
328 >                case 0:                 /* end of line */
329 >                        while (n--)
330 >                                *sp++ = 0;
331 >                        /* leaves n == -1 as flag for test after loop */
332 >                        continue;
333 >                case 1:                 /* end of bitmap */
334 >                case 2:                 /* delta */
335 >                        return BIR_UNSUPPORTED;
336 >                }
337 >                                        /* absolute mode */
338 >                if (br->hdr->compr == BI_RLE4) {
339 >                        if (len & 1)
340 >                                return BIR_UNSUPPORTED;
341 >                        len >>= 1;
342 >                }
343 >                skipOdd = len & 1;
344 >                if (len > n)
345 >                        return BIR_RLERROR;
346 >                n -= len;
347 >                while (len--) {
348 >                        if (rdbyte(val, br) == EOF)
349 >                                return BIR_TRUNCATED;
350 >                        *sp++ = val;
351 >                }
352 >                if (skipOdd && rdbyte(val, br) == EOF)
353 >                        return BIR_TRUNCATED;
354 >        }
355 >                                        /* verify break at end of line */
356 >        if (!n && (rdbyte(n, br) != 0 || (rdbyte(n, br) != 0 &&
357 >                                (n != 1 || br->yscan != br->hdr->height-1))))
358 >                return BIR_RLERROR;
359 >        if (br->seek != NULL)           /* record next scanline position */
360                  br->scanpos[br->yscan + 1] = br->fpos;
361          return BIR_OK;
362   }
# Line 270 | Line 380 | BMPseekScanline(int y, BMPReader *br)
380          if (y != br->yscan + 1 && br->seek != NULL) {
381                  int     yseek;
382                  uint32  seekp;
383 <                if (br->hdr->compr == BI_UNCOMPR) {
383 >                if (br->hdr->compr == BI_UNCOMPR ||
384 >                                        br->hdr->compr == BI_BITFIELDS) {
385                          yseek = y;
386                          seekp = br->scanpos[0] + y*getScanSiz(br->hdr);
387                  } else {
# Line 295 | Line 406 | BMPseekScanline(int y, BMPReader *br)
406  
407   /* get ith pixel from last scanline */
408   RGBquad
409 < BMPdecodePixel(int i, BMPReader *br)
409 > BMPdecodePixel(int i, const BMPReader *br)
410   {
411 +        static const uint32     std16mask[3] = {0x7c00, 0x3e0, 0x1f};
412          static const RGBquad    black = {0, 0, 0, 0};
413 +        const uint32            *mask;
414 +        const uint8             *pp;
415 +        uint32                  pval, v;
416 +        RGBquad                 cval;
417          
418          if (((br == NULL) | (i < 0)) || i >= br->hdr->width)
419                  return black;
420  
421 +        cval.padding = 0;
422 +
423          switch (br->hdr->bpp) {
424 <        case 24: {
425 <                uint8   *bgr = br->scanline + 3*i;
426 <                RGBquad cval;
427 <                cval.b = bgr[0]; cval.g = bgr[1]; cval.r = bgr[2];
428 <                cval.padding = 0;
424 >        case 24:
425 >                pp = br->scanline + 3*i;
426 >                cval.b = *pp++;
427 >                cval.g = *pp++;
428 >                cval.r = *pp;
429                  return cval;
312                }
430          case 32:
431 <                return ((RGBquad *)br->scanline)[i];
431 >                if (br->hdr->compr == BI_UNCOMPR)
432 >                        return ((RGBquad *)br->scanline)[i];
433 >                                                /* convert bit fields */
434 >                pp = br->scanline + 4*i;
435 >                pval = *pp++;
436 >                pval |= *pp++ << 8;
437 >                pval |= *pp++ << 16;
438 >                pval |= *pp << 24;
439 >                mask = BMPbitField(br->hdr);
440 >                v = pval & mask[0];
441 >                while (v & ~0xff) v >>= 8;
442 >                cval.r = v;
443 >                v = pval & mask[1];
444 >                while (v & ~0xff) v >>= 8;
445 >                cval.g = v;
446 >                v = pval & mask[2];
447 >                while (v & ~0xff) v >>= 8;
448 >                cval.b = v;
449 >                return cval;
450          case 8:
451                  return br->hdr->palette[br->scanline[i]];
452          case 1:
453 <                return br->hdr->palette[br->scanline[i>>3]>>(i&7) & 1];
453 >                return br->hdr->palette[br->scanline[i>>3]>>((7-i)&7) & 1];
454          case 4:
455 <                return br->hdr->palette[br->scanline[i>>1]>>((i&1)<<2) & 0xf];
455 >                return br->hdr->palette[br->scanline[i>>1]>>(i&1?4:0) & 0xf];
456 >        case 16:
457 >                pp = br->scanline + 2*i;
458 >                pval = *pp++;
459 >                pval |= *pp++ << 8;
460 >                mask = std16mask;
461 >                if (br->hdr->compr == BI_BITFIELDS)
462 >                        mask = BMPbitField(br->hdr);
463 >                cval.r = ((pval & mask[0]) << 8) / (mask[0] + 1);
464 >                cval.g = ((pval & mask[1]) << 8) / (mask[1] + 1);
465 >                cval.b = ((pval & mask[2]) << 8) / (mask[2] + 1);
466 >                return cval;
467          }
468          return black;                           /* should never happen */
469   }
# Line 409 | Line 555 | BMPmappedHeader(int xr, int yr, int infolen, int ncolo
555          hdr->height = yr;
556          hdr->yIsDown = 0;                       /* default to upwards order */
557          hdr->bpp = n;
558 <        hdr->compr = BI_UNCOMPR;
558 >        hdr->compr = BI_UNCOMPR;                /* compression needs seek */
559          hdr->hRes = hdr->vRes = 2835;           /* default to 72 ppi */
560          hdr->nColors = ncolors;
561          hdr->impColors = 0;                     /* says all colors important */
# Line 423 | Line 569 | BMPmappedHeader(int xr, int yr, int infolen, int ncolo
569  
570                                          /* put byte to writer */
571   #define wrbyte(c,bw)    ( (*(bw)->cput)(c,(bw)->c_data), \
572 <                                ++((bw)->fpos) > (bw)->flen ? \
572 >                                ++(bw)->fpos > (bw)->flen ? \
573                                          ((bw)->flen = (bw)->fpos) : \
574                                          (bw)->fpos )
575  
# Line 442 | Line 588 | wrint32(int32 i, BMPWriter *bw)
588          wrbyte(i& 0xff, bw);
589          wrbyte(i>>8 & 0xff, bw);
590          wrbyte(i>>16 & 0xff, bw);
591 <        wrbyte(i>>24  & 0xff, bw);
591 >        wrbyte(i>>24 & 0xff, bw);
592   }
593  
594   /* write 16-bit unsigned integer in littlendian order */
# Line 459 | Line 605 | wrseek(uint32 pos, BMPWriter *bw)
605   {
606          if (pos == bw->fpos)
607                  return BIR_OK;
608 <        if (bw->seek == NULL) {
609 <                if (pos < bw->fpos)
464 <                        return BIR_SEEKERR;
465 <                while (bw->fpos < pos)
466 <                        wrbyte(0, bw);
467 <                return BIR_OK;
468 <        }
608 >        if (bw->seek == NULL)
609 >                return BIR_SEEKERR;
610          if ((*bw->seek)(pos, bw->c_data) != 0)
611                  return BIR_SEEKERR;
612          bw->fpos = pos;
# Line 482 | Line 623 | BMPopenWriter(void (*cput)(int, void *), int (*seek)(u
623          BMPWriter       *bw;
624          uint32          hdrSiz, palSiz, scanSiz, bmSiz;
625                                                  /* check arguments */
626 <        if (cput == NULL || hdr == NULL)
626 >        if (cput == NULL)
627                  return NULL;
628 <        if (hdr->width <= 0 || hdr->height <= 0)
628 >        if (!BMPheaderOK(hdr))
629                  return NULL;
630 <        if (hdr->compr != BI_UNCOMPR && hdr->compr != BI_RLE8)
630 >        if ((hdr->bpp == 16) | (hdr->compr == BI_RLE4))
631                  return NULL;                    /* unsupported */
632 <        if (hdr->bpp > 8 && hdr->compr != BI_UNCOMPR)
632 > /* no seek means we may have the wrong file length, but most app's don't care
633 >        if (seek == NULL && ((hdr->compr == BI_RLE8) | (hdr->compr == BI_RLE4)))
634                  return NULL;
635 <        palSiz = BMPpalLen(hdr);
494 <        if (hdr->nColors > palSiz)
495 <                return NULL;
496 <        if (hdr->compr != BI_UNCOMPR && seek == NULL)
497 <                return NULL;
635 > */
636                                                  /* compute sizes */
637          hdrSiz = 2 + 6*4 + 2*2 + 6*4;
638 <        palSiz *= sizeof(RGBquad);
638 >        if (hdr->compr == BI_BITFIELDS)
639 >                hdrSiz += sizeof(uint32)*3;
640 >        palSiz = sizeof(RGBquad)*BMPpalLen(hdr);
641          scanSiz = getScanSiz(hdr);
642          bmSiz = hdr->height*scanSiz;            /* wrong if compressed */
643                                                  /* initialize writer */
# Line 547 | Line 687 | BMPopenWriter(void (*cput)(int, void *), int (*seek)(u
687   #endif
688          return bw;
689   }
690 +
691 + /* find position of next run of 5 or more identical bytes, or 255 if none */
692 + static int
693 + findNextRun(const int8 *bp, int len)
694 + {
695 +        int     pos, cnt;
696 +                                                /* look for run */
697 +        for (pos = 0; (len > 0) & (pos < 255); pos++, bp++, len--) {
698 +                if (len < 5)                    /* no hope left? */
699 +                        continue;
700 +                cnt = 1;                        /* else let's try it */
701 +                while (bp[cnt] == bp[0])
702 +                        if (++cnt >= 5)
703 +                                return pos;     /* long enough */
704 +        }
705 +        return pos;                             /* didn't find any */
706 + }
707                                  
708   /* write the current scanline */
709   int
710   BMPwriteScanline(BMPWriter *bw)
711   {
712 +        const int8      *sp;
713 +        int             n;
714 +
715          if (bw->yscan >= bw->hdr->height)
716                  return BIR_EOF;
717                                                  /* writing uncompressed? */
718 <        if (bw->hdr->compr == BI_UNCOMPR) {
718 >        if (bw->hdr->compr == BI_UNCOMPR || bw->hdr->compr == BI_BITFIELDS) {
719                  uint32  scanSiz = getScanSiz(bw->hdr);
720                  uint32  slpos = bw->fbmp + bw->yscan*scanSiz;
721                  if (wrseek(slpos, bw) != BIR_OK)
# Line 564 | Line 724 | BMPwriteScanline(BMPWriter *bw)
724                  bw->yscan++;
725                  return BIR_OK;
726          }
727 <                                                /* else write compressed */
728 < /* XXX need to do actual compression */
729 <        return BIR_UNSUPPORTED;
730 <                                                /* write file length at end */
727 >        /*
728 >         * RLE8 Encoding
729 >         *
730 >         * See the notes in BMPreadScanline() on this encoding.  Needless
731 >         * to say, we avoid the nuttier aspects of this specification.
732 >         * We also assume that every scanline ends in a line break
733 >         * (0x0000) except for the last, which ends in a bitmap break
734 >         * (0x0001).  We don't support RLE4 at all; it's too awkward.
735 >         */
736 >        sp = bw->scanline;
737 >        n = bw->hdr->width;
738 >        while (n > 0) {
739 >                int     cnt, val;
740 >
741 >                cnt = findNextRun(sp, n);       /* 0-255 < n */
742 >                if (cnt >= 3) {                 /* output non-run */
743 >                        int     skipOdd = cnt & 1;
744 >                        wrbyte(0, bw);
745 >                        wrbyte(cnt, bw);
746 >                        n -= cnt;
747 >                        while (cnt--)
748 >                                wrbyte(*sp++, bw);
749 >                        if (skipOdd)
750 >                                wrbyte(0, bw);
751 >                }
752 >                if (n <= 0)                     /* was that it? */
753 >                        break;
754 >                val = *sp;                      /* output run */
755 >                for (cnt = 1; cnt < 255; cnt++)
756 >                        if ((!--n) | (*++sp != val))
757 >                                break;
758 >                wrbyte(cnt, bw);
759 >                wrbyte(val, bw);
760 >        }
761 >        bw->yscan++;                            /* write line break or EOD */
762          if (bw->yscan == bw->hdr->height) {
763 <                if (bw->seek == NULL || (*bw->seek)(2, bw->c_data) != 0)
764 <                        return BIR_SEEKERR;
765 <                bw->fpos = 2;
766 <                wrint32(bw->flen, bw);
763 >                wrbyte(0, bw); wrbyte(1, bw);   /* end of bitmap marker */
764 >                if (wrseek(2, bw) != BIR_OK)
765 >                        return BIR_OK;          /* no one may care */
766 >                wrint32(bw->flen, bw);          /* correct file length */
767 >                if (wrseek(34, bw) != BIR_OK)
768 >                        return BIR_OK;
769 >                wrint32(bw->flen-bw->fbmp, bw); /* correct bitmap length */
770 >        } else {
771 >                wrbyte(0, bw); wrbyte(0, bw);   /* end of line marker */
772          }
773          return BIR_OK;
774   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines