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.5 by greg, Sat Mar 27 05:43:37 2004 UTC vs.
Revision 2.6 by greg, Sat Mar 27 16:33:31 2004 UTC

# Line 255 | Line 255 | BMPisGrayscale(const BMPHeader *hdr)
255                  return -1;
256          if (hdr->bpp > 8)               /* assume they had a reason for it */
257                  return 0;
258 <        for (rgbp = hdr->palette, n = hdr->impColors; n-- > 0; rgbp++)
258 >        for (rgbp = hdr->palette, n = hdr->nColors; n-- > 0; rgbp++)
259                  if (((rgbp->r != rgbp->g) | (rgbp->g != rgbp->b)))
260                          return 0;
261          return 1;                       /* all colors neutral in map */
# Line 279 | Line 279 | BMPreadScanline(BMPReader *br)
279           *
280           * Certain aspects of this scheme are completely insane, so
281           * we don't support them.  Fortunately, they rarely appear.
282 <         * One is the mid-file EOD (0x0001) and another is the insane
282 >         * One is the mid-file EOD (0x0001) and another is the ill-conceived
283           * "delta" (0x0002), which is like a "goto" statement for bitmaps.
284           * Whoever thought this up should be shot, then told why
285 <         * it's impossible to support in any reasonable way.
285 >         * it's impossible to support such a scheme in any reasonable way.
286           * Also, RLE4 mode allows runs to stop halfway through a byte,
287           * which is likewise uncodeable, so we don't even try.
288           * Finally, the scanline break is ambiguous -- we assume here that
# Line 291 | Line 291 | BMPreadScanline(BMPReader *br)
291           * the end of the scanline, assuming the next bit of data belongs
292           * the following scan.  If a break follows the last pixel, as it
293           * seems to in the files I've tested out of Photoshop, you end up
294 <         * painting every other line black.  BTW, I assume any skipped
294 >         * painting every other line black.  Also, I assume any skipped
295           * pixels are painted with color 0, which is often black.  Nowhere
296           * is it specified what we should assume for missing pixels.  This
297           * is undoubtedly the most brain-dead format I've ever encountered.
# Line 323 | Line 323 | BMPreadScanline(BMPReader *br)
323                  case 0:                 /* end of line */
324                          while (n--)
325                                  *sp++ = 0;
326 +                        /* leaves n == -1 as flag for test after loop */
327                          continue;
328                  case 1:                 /* end of bitmap */
329                  case 2:                 /* delta */
# Line 347 | Line 348 | BMPreadScanline(BMPReader *br)
348                          return BIR_TRUNCATED;
349          }
350                                          /* verify break at end of line */
351 <        if (rdbyte(n, br) != 0 || (rdbyte(n, br) != 0 &&
352 <                                (n != 1 || br->yscan != br->hdr->height-1)))
351 >        if (!n && (rdbyte(n, br) != 0 || (rdbyte(n, br) != 0 &&
352 >                                (n != 1 || br->yscan != br->hdr->height-1))))
353                  return BIR_RLERROR;
354          if (br->seek != NULL)           /* record next scanline position */
355                  br->scanpos[br->yscan + 1] = br->fpos;
# Line 763 | Line 764 | BMPwriteScanline(BMPWriter *bw)
764                  if (bw->seek == NULL || (*bw->seek)(2, bw->c_data) != 0)
765                          return BIR_OK;          /* no one may care */
766                  bw->fpos = 2;
767 <                wrint32(bw->flen-bw->fbmp, bw); /* output correct bitmap length */
767 >                wrint32(bw->flen-bw->fbmp, bw); /* correct bitmap length */
768          } else {
769                  wrbyte(0, bw); wrbyte(0, bw);   /* end of line marker */
770          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines