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

Comparing ray/src/px/x11image.c (file contents):
Revision 2.46 by greg, Wed Apr 16 20:28:47 1997 UTC vs.
Revision 2.49 by greg, Thu Apr 24 17:29:53 1997 UTC

# Line 178 | Line 178 | char  *argv[];
178                                  break;
179                          case 'e':                       /* exposure comp. */
180                                  i++;
181 <                                if (!strcmp(argv[i], "auto")) {
181 >                                if (argv[i][0] == 'a') {
182                                          tmflags = TM_F_CAMERA;
183                                          break;
184                                  }
185 <                                if (!strcmp(argv[i], "human")) {
185 >                                if (argv[i][0] == 'h') {
186                                          tmflags = TM_F_HUMAN;
187                                          break;
188                                  }
# Line 944 | Line 944 | COLOR  clr;
944  
945   make_tonemap()                  /* initialize tone mapping */
946   {
947 <        int  y;
947 >        int  flags, y;
948  
949          if (tmflags != -1 && fname == NULL) {
950                  fprintf(stderr, "%s: cannot adjust tone of standard input\n",
951                                  progname);
952                  tmflags = -1;
953          }
954 <        if (tmflags == -1) {
954 >        if (tmflags == -1) {            /* linear with clamping */
955                  setcolrcor(pow, 1.0/gamcor);
956                  return;
957          }
958 <        if (greyscale)
959 <                tmflags |= TM_F_BW;
960 <                                        /* initialize tm library */
961 <        if (tmInit(tmflags, stdprims, gamcor) == NULL)
962 <                goto memerr;
963 <        if (tmSetSpace(stdprims, WHTEFFICACY/exposure))
964 <                goto tmerr;
965 <                                        /* allocate encoding buffers */
966 <        if ((lscan = (TMbright *)malloc(xmax*sizeof(TMbright))) == NULL)
967 <                goto memerr;
968 <        if (tmflags & TM_F_BW) {
969 <                cscan = TM_NOCHROM;
970 <                if ((pscan = (BYTE *)malloc(sizeof(BYTE)*xmax)) == NULL)
958 >        flags = tmflags;                /* histogram adjustment */
959 >        if (greyscale) flags |= TM_F_BW;
960 >        if (tmTop != NULL) {            /* reuse old histogram if one */
961 >                tmTop->flags = flags;
962 >        } else {                        /* else initialize */
963 >                if ((lscan = (TMbright *)malloc(xmax*sizeof(TMbright))) == NULL)
964                          goto memerr;
965 <        } else if ((pscan=cscan = (BYTE *)malloc(3*sizeof(BYTE)*xmax)) == NULL)
966 <                goto memerr;
967 <                                        /* compute picture histogram */
968 <        for (y = 0; y < ymax; y++) {
969 <                getscan(y);
970 <                if (tmCvColrs(lscan, TM_NOCHROM, scanline, xmax))
965 >                if (greyscale) {
966 >                        cscan = TM_NOCHROM;
967 >                        if ((pscan = (BYTE *)malloc(sizeof(BYTE)*xmax)) == NULL)
968 >                                goto memerr;
969 >                } else if ((pscan=cscan = (BYTE *)malloc(3*sizeof(BYTE)*xmax))
970 >                                == NULL)
971 >                        goto memerr;
972 >                                                /* initialize tm library */
973 >                if (tmInit(flags, stdprims, gamcor) == NULL)
974 >                        goto memerr;
975 >                if (tmSetSpace(stdprims, WHTEFFICACY/exposure))
976                          goto tmerr;
977 <                if (tmAddHisto(lscan, xmax, 1))
978 <                        goto tmerr;
977 >                                                /* compute picture histogram */
978 >                for (y = 0; y < ymax; y++) {
979 >                        getscan(y);
980 >                        if (tmCvColrs(lscan, TM_NOCHROM, scanline, xmax))
981 >                                goto tmerr;
982 >                        if (tmAddHisto(lscan, xmax, 1))
983 >                                goto tmerr;
984 >                }
985          }
986 <                                        /* compute tone mapping */
986 >                                        /* (re)compute tone mapping */
987          if (tmComputeMapping(gamcor, 0., 0.))
988                  goto tmerr;
985        free((char *)lscan);
989          return;
990   memerr:
991          quiterr("out of memory in make_tonemap");
# Line 1010 | Line 1013 | int  len;
1013          if (tmMapPixels(pscan, lscan, cscan, len))
1014                  goto tmerr;
1015          ps = pscan;
1016 <        if (tmflags & TM_F_BW)
1016 >        if (greyscale)
1017                  while (len--) {
1018                          scn[0][RED] = scn[0][GRN] = scn[0][BLU] = *ps++;
1019                          scn[0][EXP] = COLXS;
# Line 1030 | Line 1033 | tmerr:
1033   }
1034  
1035  
1033 done_tonemap()                  /* clean up after tone mapping is done */
1034 {
1035        if (tmflags == -1 || tmTop == NULL)
1036                return;
1037        tmDone(tmTop);                  /* clear old mapping */
1038        free((char *)lscan);            /* free memory */
1039        free((char *)pscan);
1040 }
1041
1042
1036   getmono()                       /* get monochrome data */
1037   {
1038          register unsigned char  *dp;
# Line 1148 | Line 1141 | getfull()                      /* get full (24-bit) data */
1141                                          (unsigned int4)scanline[x][GRN] << 8 |
1142                                          (unsigned int4)scanline[x][BLU] << 16 ;
1143          }
1151        done_tonemap();
1144   }
1145  
1146  
# Line 1176 | Line 1168 | getgrey()                      /* get greyscale data */
1168          for (x = 0; x < maxcolors; x++)
1169                  clrtab[x][RED] = clrtab[x][GRN] =
1170                          clrtab[x][BLU] = ((int4)x*256 + 128)/maxcolors;
1179        done_tonemap();
1171   }
1172  
1173  
# Line 1209 | Line 1200 | getmapped()                    /* get color-mapped data */
1200                  else
1201                          map_colrs(ourdata+y*xmax, scanline, xmax);
1202          }
1212        done_tonemap();
1203   }
1204  
1205  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines