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

Comparing src/px/ra_bmp.c (file contents):
Revision 2.18 by greg, Sun Sep 14 04:39:53 2025 UTC vs.
Revision 2.20 by greg, Sun Sep 14 17:11:29 2025 UTC

# Line 31 | Line 31 | extern void info2rad(char *infs, int len, FILE *fout);
31   extern char *growInfo(int n);
32   extern gethfunc headline;
33  
34 < #define add2info(s)     strcpy(growInfo(strlen(s)), s)
34 > #define add2info(s)     {int _n=strlen(s); memcpy(growInfo(_n), s, _n+1);}
35   #define clearInfo()     growInfo(-infolen)
36  
37   RGBPRIMP        rgbinp = stdprims;      /* RGB input primitives */
# Line 289 | Line 289 | headline(char *s, void *p)
289   void
290   addBMPcspace(RGBPRIMP pp, double gamma)
291   {
292 <        char    ibuf[128];
292 >        char    ibuf[196];
293 >        char    *cp = ibuf;
294  
295 +        sprintf(cp, "GAMMA=%.2f\n", gamma);
296 +        cp += strlen(cp);
297          if (pp != NULL) {
298 <                sprintf(ibuf,
298 >                sprintf(cp,
299                          "%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",
300                                  PRIMARYSTR,
301                                  pp[RED][CIEX],pp[RED][CIEY],
302                                  pp[GRN][CIEX],pp[GRN][CIEY],
303                                  pp[BLU][CIEX],pp[BLU][CIEY],
304                                  pp[WHT][CIEX],pp[WHT][CIEY]);
305 <                add2info(ibuf);
305 >                /* cp += strlen(cp); */
306          }
304        sprintf(ibuf, "GAMMA=%.2f\n", gamma);
307          add2info(ibuf);
308   }
309  
# Line 319 | Line 321 | info2rad(char *infs, int len, FILE *fout)
321                                          /* check for gamma */
322          if ((cp = strstr(infs, "GAMMA=")) != NULL) {
323                                          /* copy what came before */
324 <                fwrite(infs, cp-infs, 1, fout);
324 >                fwrite(infs, 1, cp-infs, fout);
325                  cp += 6;
326                  gamcor = atof(cp);      /* record setting */
327                  while (*cp++ != '\n')
# Line 380 | Line 382 | rad2bmp(FILE *rfp, BMPWriter *bwr, int inv, RGBPRIMP m
382                          }
383                  else if (bradj)
384                          shiftcolrs(scanin, bwr->hdr->width, bradj);
385 <                if (monpri == NULL && rgbinp != TM_XYZPRIM)
385 >                if ((monpri == NULL) & (rgbinp != TM_XYZPRIM))
386                          for (x = bwr->hdr->width; x--; )
387                                  scanin[x][GRN] = normbright(scanin[x]);
388                  colrs_gambs(scanin, bwr->hdr->width);
# Line 461 | Line 463 | tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM
463                  tmflags = TM_F_LINEAR;
464          else
465                  quiterr("illegal exposure specification (auto|human|linear)");
466 <        if (monpri == NULL) {
467 <                tmflags |= TM_F_BW;
466 <                monpri = stdprims;
467 <        }
466 >
467 >        tmflags |= (monpri == NULL)*TM_F_BW;
468                                          /* open Radiance input */
469          if (fnin == NULL)
470                  fp = stdin;
# Line 473 | Line 473 | tmap2bmp(char *fnin, char *fnout, char *expec, RGBPRIM
473                  exit(1);
474          }
475                                          /* tone-map picture */
476 <        if (tmMapPicture(&pa, &xr, &yr, tmflags, monpri, gamval,
476 >        if (tmMapPicture(&pa, &xr, &yr, tmflags,
477 >                        tmflags&TM_F_BW ? stdprims : monpri, gamval,
478                          0., 0., fnin, fp) != TM_E_OK)
479                  exit(1);
480                                          /* try to retrieve info */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines