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.13 by greg, Fri Mar 18 21:04:05 2005 UTC vs.
Revision 2.16 by schorsch, Thu Mar 10 01:49:00 2016 UTC

# Line 188 | Line 188 | BMPopenReader(int (*cget)(void *), int (*seek)(uint32,
188          br->hdr->hRes = rdint32(br);            /* horizontal resolution */
189          br->hdr->vRes = rdint32(br);            /* vertical resolution */
190          br->hdr->nColors = rdint32(br);         /* # colors used */
191 +        if (!br->hdr->nColors && br->hdr->bpp <= 8)
192 +                br->hdr->nColors = 1<<br->hdr->bpp;
193          br->hdr->impColors = rdint32(br);       /* # important colors */
194          if (br->hdr->impColors < 0)
195                  goto err;                       /* catch premature EOF */
# Line 257 | Line 259 | BMPisGrayscale(const BMPHeader *hdr)
259                  return -1;
260          if (hdr->bpp > 8)               /* assume they had a reason for it */
261                  return 0;
262 <        for (rgbp = hdr->palette, n = hdr->nColors; n-- > 0; rgbp++)
263 <                if (((rgbp->r != rgbp->g) | (rgbp->g != rgbp->b)))
262 >        for (rgbp = hdr->palette, n = hdr->impColors; n-- > 0; rgbp++)
263 >                if ((rgbp->r != rgbp->g) | (rgbp->g != rgbp->b))
264                          return 0;
265          return 1;                       /* all colors neutral in map */
266   }
# Line 298 | Line 300 | BMPreadScanline(BMPReader *br)
300           * is it specified what we should assume for missing pixels.  This
301           * is undoubtedly the most brain-dead format I've ever encountered.
302           */
303 <        sp = br->scanline;
303 >        sp = (int8 *)br->scanline;
304          n = br->hdr->width;
305          if (br->hdr->compr == BI_RLE4)
306                  n = (n + 1) >> 1;
# Line 546 | Line 548 | BMPmappedHeader(int xr, int yr, int infolen, int ncolo
548                  n = 8;
549          else
550                  return NULL;
551 +        /* XXX VC warns about 32 bit shift coerced to 64 bit */
552          hdr = (BMPHeader *)malloc(sizeof(BMPHeader) +
553                                          sizeof(RGBquad)*(1<<n) -
554                                          sizeof(hdr->palette) +
# Line 561 | Line 564 | BMPmappedHeader(int xr, int yr, int infolen, int ncolo
564          hdr->nColors = ncolors;
565          hdr->impColors = 0;                     /* says all colors important */
566          hdr->infoSiz = infolen;
567 +        /* XXX VC warns about 32 bit shift coerced to 64 bit */
568          memset((void *)hdr->palette, 0, sizeof(RGBquad)*(1<<n) + infolen);
569          for (n = ncolors; n--; )
570                  hdr->palette[n].r = hdr->palette[n].g =
# Line 734 | Line 738 | BMPwriteScanline(BMPWriter *bw)
738           * (0x0000) except for the last, which ends in a bitmap break
739           * (0x0001).  We don't support RLE4 at all; it's too awkward.
740           */
741 <        sp = bw->scanline;
741 >        sp = (const int8 *)bw->scanline;
742          n = bw->hdr->width;
743          while (n > 0) {
744                  int     cnt, val;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines