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.32 by greg, Thu Oct 28 11:39:59 1993 UTC vs.
Revision 2.44 by greg, Tue Apr 15 16:53:58 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1997 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 27 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27   #include  <X11/Xutil.h>
28   #include  <X11/Xatom.h>
29  
30 < #include  "color.h"
30 > #include  "tonemap.h"
31   #include  "view.h"
32   #include  "x11raster.h"
33   #include  "random.h"
34   #include  "resolu.h"
35  
36 #ifdef  __alpha
37 #define  int4           int
38 #endif
36   #ifndef  int4
37 < #define  int4           long
37 > #define  int4           int             /* most int's are 32-bit */
38   #endif
39  
40   #define  FONTNAME       "8x13"          /* text font we'll use */
# Line 56 | Line 53 | static char SCCSid[] = "$SunId$ LBL";
53   #define  redraw(x,y,w,h) patch_raster(wind,(x)-xoff,(y)-yoff,x,y,w,h,ourras)
54  
55   double  gamcor = 2.2;                   /* gamma correction */
56 + char  *gamstr = NULL;                   /* gamma value override */
57  
58   int  dither = 1;                        /* dither colors? */
59   int  fast = 0;                          /* keep picture in Pixmap? */
# Line 73 | Line 71 | int  xoff = 0;                         /* x image offset */
71   int  yoff = 0;                          /* y image offset */
72  
73   int  parent = 0;                        /* number of children, -1 if child */
74 + int  sequential = 0;                    /* display images in sequence */
75  
76 + char  *tout = "od";                     /* output of 't' command */
77 + int  tinterv = 0;                       /* interval between mouse reports */
78 +
79 + int  tmflags = -1;                      /* tone mapping flags (-1 for none) */
80 +
81   VIEW  ourview = STDVIEW;                /* image view parameters */
82   int  gotview = 0;                       /* got parameters from file */
83  
84   COLR  *scanline;                        /* scan line buffer */
85 + TMbright  *lscan;                       /* encoded luminance scanline */
86 + BYTE  *cscan;                           /* encoded chroma scanline */
87 + BYTE  *pscan;                           /* compute pixel scanline */
88  
89   RESOLU  inpres;                         /* input resolution and ordering */
90   int  xmax, ymax;                        /* picture dimensions */
# Line 112 | Line 119 | char  *progname;
119  
120   char  errmsg[128];
121  
122 < extern BYTE  clrtab[256][3];            /* global color map */
122 > BYTE  clrtab[256][3];                   /* global color map */
123  
124   extern long  ftell();
125  
126 + extern char  *getenv();
127 +
128   Display  *thedisplay;
129   Atom  closedownAtom, wmProtocolsAtom;
130  
# Line 128 | Line 137 | main(argc, argv)
137   int  argc;
138   char  *argv[];
139   {
131        extern char  *getenv();
132        char  *gv;
140          int  headline();
141          int  i;
142          int  pid;
143          
144          progname = argv[0];
138        if ((gv = getenv("GAMMA")) != NULL)
139                gamcor = atof(gv);
145  
146          for (i = 1; i < argc; i++)
147                  if (argv[i][0] == '-')
148                          switch (argv[i][1]) {
149 <                        case 'c':
149 >                        case 'c':                       /* number of colors */
150                                  maxcolors = atoi(argv[++i]);
151                                  break;
152 <                        case 'b':
152 >                        case 'b':                       /* greyscale only */
153                                  greyscale = !greyscale;
154                                  break;
155 <                        case 'm':
155 >                        case 'm':                       /* monochrome */
156 >                                greyscale = 1;
157                                  maxcolors = 2;
158                                  break;
159 <                        case 'd':
159 >                        case 'd':                       /* display or dither */
160                                  if (argv[i][2] == 'i')
161                                          dispname = argv[++i];
162                                  else
163                                          dither = !dither;
164                                  break;
165 <                        case 'f':
165 >                        case 'f':                       /* save pixmap */
166                                  fast = !fast;
167                                  break;
168 <                        case 'e':
169 <                                if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
168 >                        case 's':                       /* one at a time */
169 >                                sequential = !sequential;
170 >                                break;
171 >                        case 'o':                       /* 't' output */
172 >                                tout = argv[i]+2;
173 >                                break;
174 >                        case 't':                       /* msec interval */
175 >                                tinterv = atoi(argv[++i]);
176 >                                break;
177 >                        case 'e':                       /* exposure comp. */
178 >                                i++;
179 >                                if (!strcmp(argv[i], "auto")) {
180 >                                        tmflags = TM_F_CAMERA;
181 >                                        break;
182 >                                }
183 >                                if (!strcmp(argv[i], "human")) {
184 >                                        tmflags = TM_F_HUMAN;
185 >                                        break;
186 >                                }
187 >                                if (argv[i][0] != '+' && argv[i][0] != '-')
188                                          goto userr;
189 <                                scale = atoi(argv[++i]);
189 >                                scale = atoi(argv[i]);
190                                  break;
191 <                        case 'g':
191 >                        case 'g':                       /* gamma comp. */
192                                  if (argv[i][2] == 'e')
193                                          geometry = argv[++i];
194                                  else
195 <                                        gamcor = atof(argv[++i]);
195 >                                        gamstr = argv[++i];
196                                  break;
197                          default:
198                                  goto userr;
# Line 197 | Line 221 | char  *argv[];
221          if (i < argc) {                 /* open picture file */
222                  fname = argv[i];
223                  fin = fopen(fname, "r");
224 <                if (fin == NULL) {
225 <                        sprintf(errmsg, "cannot open file \"%s\"", fname);
202 <                        quiterr(errmsg);
203 <                }
224 >                if (fin == NULL)
225 >                        quiterr("cannot open picture file");
226          }
227                                  /* get header */
228          getheader(fin, headline, NULL);
# Line 217 | Line 239 | char  *argv[];
239  
240          init(argc, argv);                       /* get file and open window */
241  
220        if (parent < 0) {
221                kill(getppid(), SIGCONT);       /* signal parent if child */
222                sigrecv--;
223        }
242          for ( ; ; )
243                  getevent();             /* main loop */
244   userr:
245          fprintf(stderr,
246 < "Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops] pic ..\n",
246 > "Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e spec][-g gamcor][-s][-ospec][-t intvl] pic ..\n",
247                          progname);
248          exit(1);
249   }
# Line 238 | Line 256 | char  *s;
256  
257          if (isexpos(s))
258                  exposure *= exposval(s);
259 <        else if (isformat(s)) {
242 <                formatval(fmt, s);
259 >        else if (formatval(fmt, s))
260                  wrongformat = strcmp(fmt, COLRFMT);
261 <        } else if (isview(s) && sscanview(&ourview, s) > 0)
261 >        else if (isview(s) && sscanview(&ourview, s) > 0)
262                  gotview++;
263   }
264  
# Line 275 | Line 292 | char **argv;
292          name += i+1;
293          if ((thedisplay = XOpenDisplay(dispname)) == NULL)
294                  quiterr("cannot open display");
295 +                                /* set gamma value */
296 +        if (gamstr == NULL)             /* get it from the X server */
297 +                gamstr = XGetDefault(thedisplay, "radiance", "gamma");
298 +        if (gamstr == NULL)             /* get it from the environment */
299 +                gamstr = getenv("DISPLAY_GAMMA");
300 +        if (gamstr != NULL)
301 +                gamcor = atof(gamstr);
302                                  /* get best visual for default screen */
303          getbestvis();
304                                  /* store image */
# Line 301 | Line 325 | char **argv;
325                  }
326          }
327          /* open window */
328 +        i = CWEventMask|CWCursor|CWBackPixel|CWBorderPixel;
329          ourwinattr.border_pixel = ourwhite;
330          ourwinattr.background_pixel = ourblack;
331 <        ourwinattr.colormap = XCreateColormap(thedisplay, ourroot,
332 <                        ourvis.visual, AllocNone);
331 >        if (ourvis.visual != DefaultVisual(thedisplay,ourscreen)) {
332 >                ourwinattr.colormap = newcmap(thedisplay, ourscreen, ourvis.visual);
333 >                i |= CWColormap;
334 >        }
335          ourwinattr.event_mask = ExposureMask|KeyPressMask|ButtonPressMask|
336                          ButtonReleaseMask|ButtonMotionMask|StructureNotifyMask;
337          ourwinattr.cursor = XCreateFontCursor(thedisplay, XC_diamond_cross);
338          wind = XCreateWindow(thedisplay, ourroot, xszhints.x, xszhints.y,
339                          xszhints.width, xszhints.height, BORWIDTH,
340 <                        ourvis.depth, InputOutput, ourvis.visual, CWEventMask|
341 <                        CWCursor|CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr);
340 >                        ourvis.depth, InputOutput, ourvis.visual,
341 >                        i, &ourwinattr);
342          if (wind == 0)
343                  quiterr("cannot create window");
344          width = xmax;
# Line 349 | Line 376 | char **argv;
376          XSetWMProtocols(thedisplay, wind, &closedownAtom, 1);
377  
378          XMapWindow(thedisplay, wind);
352        return;
379   } /* end of init */
380  
381  
# Line 362 | Line 388 | char  *err;
388          if (es = err != NULL)
389                  fprintf(stderr, "%s: %s: %s\n", progname,
390                                  fname==NULL?"<stdin>":fname, err);
391 <        if (parent > 0 & wind != 0) {
392 <                XDestroyWindow(thedisplay, wind);
393 <                XFlush(thedisplay);
368 <        } else if (parent < 0 & sigrecv == 0)
391 >        if (thedisplay != NULL)
392 >                XCloseDisplay(thedisplay);
393 >        if (parent < 0 & sigrecv == 0)
394                  kill(getppid(), SIGCONT);
395          while (parent > 0 && wait(&cs) != -1) { /* wait for any children */
396                  if (es == 0)
# Line 529 | Line 554 | getras()                               /* get raster file */
554                                  xmax, ymax, 8);
555                  if (ourras == NULL)
556                          goto fail;
557 <                if (greyscale | ourvis.class == StaticGray)
557 >                if (greyscale)
558                          getgrey();
559                  else
560                          getmapped();
# Line 559 | Line 584 | getevent()                             /* process the next event */
584                  map_rcolors(ourras, wind);
585                  if (fast)
586                          make_rpixmap(ourras, wind);
587 +                if (!sequential & parent < 0 & sigrecv == 0) {
588 +                        kill(getppid(), SIGCONT);
589 +                        sigrecv--;
590 +                }
591                  break;
592          case UnmapNotify:
593                  if (!fast)
# Line 571 | Line 600 | getevent()                             /* process the next event */
600          case ButtonPress:
601                  if (xev.xbutton.state & (ShiftMask|ControlMask))
602                          moveimage(&xev.xbutton);
574                else if (xev.xbutton.button == Button2)
575                        traceray(xev.xbutton.x, xev.xbutton.y);
603                  else
604 <                        getbox(&xev.xbutton);
604 >                        switch (xev.xbutton.button) {
605 >                        case Button1:
606 >                                getbox(&xev.xbutton);
607 >                                break;
608 >                        case Button2:
609 >                                traceray(xev.xbutton.x, xev.xbutton.y);
610 >                                break;
611 >                        case Button3:
612 >                                trackrays(&xev.xbutton);
613 >                                break;
614 >                        }
615                  break;
616          case ClientMessage:
617                  if ((xev.xclient.message_type == wmProtocolsAtom) &&
# Line 585 | Line 622 | getevent()                             /* process the next event */
622   }
623  
624  
625 < traceray(xpos, ypos)                    /* print ray corresponding to pixel */
625 > traceray(xpos, ypos)                    /* print requested pixel data */
626   int  xpos, ypos;
627   {
628 +        extern char  *index();
629          FLOAT  hv[2];
630          FVECT  rorg, rdir;
631 +        COLOR  cval;
632 +        register char  *cp;
633  
634 <        if (!gotview) {         /* no view, no can do */
635 <                XBell(thedisplay, 0);
636 <                return(-1);
637 <        }
634 >        box.xmin = xpos; box.xsiz = 1;
635 >        box.ymin = ypos; box.ysiz = 1;
636 >        avgbox(cval);
637 >        scalecolor(cval, 1./exposure);
638          pix2loc(hv, &inpres, xpos-xoff, ypos-yoff);
639 <        if (viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0)
640 <                return(-1);
641 <        printf("%e %e %e ", rorg[0], rorg[1], rorg[2]);
642 <        printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]);
639 >        if (!gotview || viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0)
640 >                rorg[0] = rorg[1] = rorg[2] =
641 >                rdir[0] = rdir[1] = rdir[2] = 0.;
642 >
643 >        for (cp = tout; *cp; cp++)      /* print what they asked for */
644 >                switch (*cp) {
645 >                case 'o':                       /* origin */
646 >                        printf("%e %e %e ", rorg[0], rorg[1], rorg[2]);
647 >                        break;
648 >                case 'd':                       /* direction */
649 >                        printf("%e %e %e ", rdir[0], rdir[1], rdir[2]);
650 >                        break;
651 >                case 'v':                       /* radiance value */
652 >                        printf("%e %e %e ", colval(cval,RED),
653 >                                        colval(cval,GRN), colval(cval,BLU));
654 >                        break;
655 >                case 'l':                       /* luminance */
656 >                        printf("%e ", luminance(cval));
657 >                        break;
658 >                case 'p':                       /* pixel position */
659 >                        printf("%d %d ", (int)(hv[0]*inpres.xr),
660 >                                        (int)(hv[1]*inpres.yr));
661 >                        break;
662 >                }
663 >        putchar('\n');
664          fflush(stdout);
665          return(0);
666   }
# Line 674 | Line 735 | XKeyPressedEvent  *ekey;
735          case '@':                               /* adaptation level */
736                  if (avgbox(cval) == -1)
737                          return(-1);
738 <                comp = com=='@'
739 <                ? 106./pow(1.219+pow(luminance(cval)/exposure,.4),2.5)/exposure
740 <                : .5/bright(cval) ;
738 >                comp = bright(cval);
739 >                if (comp < 1e-20) {
740 >                        XBell(thedisplay, 0);
741 >                        return(-1);
742 >                }
743 >                if (com == '@')
744 >                        comp = 106./exposure/
745 >                        pow(1.219+pow(comp*WHTEFFICACY/exposure,.4),2.5);
746 >                else
747 >                        comp = .5/comp;
748                  comp = log(comp)/.69315 - scale;
749                  n = comp < 0 ? comp-.5 : comp+.5 ;      /* round */
750 <                if (n == 0)
751 <                        return(0);
752 <                scale_rcolors(ourras, pow(2.0, (double)n));
750 >                if (tmflags != -1)
751 >                        tmflags = -1;           /* turn off tone mapping */
752 >                else {
753 >                        if (n == 0)             /* else check if any change */
754 >                                return(0);
755 >                        scale_rcolors(ourras, pow(2.0, (double)n));
756 >                }
757                  scale += n;
758                  sprintf(buf, "%+d", scale);
759                  XDrawImageString(thedisplay, wind, ourgc,
# Line 778 | Line 850 | XButtonPressedEvent  *ebut;
850   }
851  
852  
853 + trackrays(ebut)                         /* trace rays as mouse moves */
854 + XButtonPressedEvent  *ebut;
855 + {
856 +        XEvent  e;
857 +        unsigned long   lastrept;
858 +
859 +        traceray(ebut->x, ebut->y);
860 +        lastrept = ebut->time;
861 +        XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e);
862 +        while (e.type == MotionNotify) {
863 +                if (e.xmotion.time >= lastrept + tinterv) {
864 +                        traceray(e.xmotion.x, e.xmotion.y);
865 +                        lastrept = e.xmotion.time;
866 +                }
867 +                XMaskEvent(thedisplay,ButtonReleaseMask|ButtonMotionMask,&e);
868 +        }
869 + }
870 +
871 +
872   revbox(x0, y0, x1, y1)                  /* draw box with reversed lines */
873   int  x0, y0, x1, y1;
874   {
# Line 836 | Line 927 | COLOR  clr;
927   }
928  
929  
930 + make_tonemap()                  /* initialize tone mapping */
931 + {
932 +        int  y;
933 +
934 +        if (tmflags != -1 && fname == NULL) {
935 +                fprintf(stderr, "%s: cannot adjust tone of standard input\n",
936 +                                progname);
937 +                tmflags = -1;
938 +        }
939 +        if (tmflags == -1) {
940 +                setcolrcor(pow, 1.0/gamcor);
941 +                return;
942 +        }
943 +        if (greyscale)
944 +                tmflags |= TM_F_BW;
945 +                                        /* initialize tm library */
946 +        if (tmInit(tmflags, stdprims, gamcor) == NULL)
947 +                goto memerr;
948 +        if (tmSetSpace(stdprims, WHTEFFICACY/exposure))
949 +                goto tmerr;
950 +                                        /* allocate encoding buffers */
951 +        if ((lscan = (TMbright *)malloc(xmax*sizeof(TMbright))) == NULL)
952 +                goto memerr;
953 +        if (tmflags & TM_F_BW) {
954 +                cscan = TM_NOCHROM;
955 +                if ((pscan = (BYTE *)malloc(sizeof(BYTE)*xmax)) == NULL)
956 +                        goto memerr;
957 +        } else if ((pscan=cscan = (BYTE *)malloc(3*sizeof(BYTE)*xmax)) == NULL)
958 +                goto memerr;
959 +                                        /* compute picture histogram */
960 +        for (y = 0; y < ymax; y++) {
961 +                getscan(y);
962 +                if (tmCvColrs(lscan, TM_NOCHROM, scanline, xmax))
963 +                        goto tmerr;
964 +                if (tmAddHisto(lscan, xmax, 1))
965 +                        goto tmerr;
966 +        }
967 +                                        /* compute tone mapping */
968 +        if (tmComputeMapping(gamcor, 0., 0.))
969 +                goto tmerr;
970 +        free((char *)lscan);
971 +        return;
972 + memerr:
973 +        quiterr("out of memory in make_tonemap");
974 + tmerr:
975 +        quiterr("tone mapping error");
976 + }
977 +
978 +
979 + tmap_colrs(scn, len)            /* apply tone mapping to scanline */
980 + register COLR  *scn;
981 + int  len;
982 + {
983 +        register BYTE  *ps;
984 +
985 +        if (tmflags == -1) {
986 +                if (scale)
987 +                        shiftcolrs(scn, len, scale);
988 +                colrs_gambs(scn, len);
989 +                return;
990 +        }
991 +        if (len > xmax)
992 +                quiterr("code error 1 in tmap_colrs");
993 +        if (tmCvColrs(lscan, cscan, scn, len))
994 +                goto tmerr;
995 +        if (tmMapPixels(pscan, lscan, cscan, len))
996 +                goto tmerr;
997 +        ps = pscan;
998 +        if (tmflags & TM_F_BW)
999 +                while (len--) {
1000 +                        scn[0][RED] = scn[0][GRN] = scn[0][BLU] = *ps++;
1001 +                        scn[0][EXP] = COLXS;
1002 +                        scn++;
1003 +                }
1004 +        else
1005 +                while (len--) {
1006 +                        scn[0][RED] = *ps++;
1007 +                        scn[0][GRN] = *ps++;
1008 +                        scn[0][BLU] = *ps++;
1009 +                        scn[0][EXP] = COLXS;
1010 +                        scn++;
1011 +                }
1012 +        return;
1013 + tmerr:
1014 +        quiterr("tone mapping error");
1015 + }
1016 +
1017 +
1018 + done_tonemap()                  /* clean up after tone mapping is done */
1019 + {
1020 +        if (tmflags == -1 || tmTop == NULL)
1021 +                return;
1022 +        tmDone(tmTop);                  /* clear old mapping */
1023 +        free((char *)lscan);            /* free memory */
1024 +        free((char *)pscan);
1025 + }
1026 +
1027 +
1028   getmono()                       /* get monochrome data */
1029   {
1030          register unsigned char  *dp;
# Line 925 | Line 1114 | getfull()                      /* get full (24-bit) data */
1114          int     y;
1115          register unsigned int4  *dp;
1116          register int    x;
1117 <                                        /* set gamma correction */
1118 <        setcolrgam(gamcor);
1117 >                                        /* initialize tone mapping */
1118 >        make_tonemap();
1119                                          /* read and convert file */
1120          dp = (unsigned int4 *)ourdata;
1121          for (y = 0; y < ymax; y++) {
1122                  getscan(y);
1123                  add2icon(y, scanline);
1124 <                if (scale)
936 <                        shiftcolrs(scanline, xmax, scale);
937 <                colrs_gambs(scanline, xmax);
1124 >                tmap_colrs(scanline, xmax);
1125                  if (ourras->image->blue_mask & 1)
1126                          for (x = 0; x < xmax; x++)
1127 <                                *dp++ = scanline[x][RED] << 16 |
1128 <                                        scanline[x][GRN] << 8 |
1129 <                                        scanline[x][BLU] ;
1127 >                                *dp++ = (unsigned int4)scanline[x][RED] << 16 |
1128 >                                        (unsigned int4)scanline[x][GRN] << 8 |
1129 >                                        (unsigned int4)scanline[x][BLU] ;
1130                  else
1131                          for (x = 0; x < xmax; x++)
1132 <                                *dp++ = scanline[x][RED] |
1133 <                                        scanline[x][GRN] << 8 |
1134 <                                        scanline[x][BLU] << 16 ;
1132 >                                *dp++ = (unsigned int4)scanline[x][RED] |
1133 >                                        (unsigned int4)scanline[x][GRN] << 8 |
1134 >                                        (unsigned int4)scanline[x][BLU] << 16 ;
1135          }
1136 +        done_tonemap();
1137   }
1138  
1139  
# Line 954 | Line 1142 | getgrey()                      /* get greyscale data */
1142          int     y;
1143          register unsigned char  *dp;
1144          register int    x;
1145 <                                        /* set gamma correction */
1146 <        setcolrgam(gamcor);
1145 >                                        /* initialize tone mapping */
1146 >        make_tonemap();
1147                                          /* read and convert file */
1148          dp = ourdata;
1149          for (y = 0; y < ymax; y++) {
1150                  getscan(y);
1151                  add2icon(y, scanline);
1152 <                if (scale)
965 <                        shiftcolrs(scanline, xmax, scale);
966 <                for (x = 0; x < xmax; x++)
967 <                        scanline[x][GRN] = normbright(scanline[x]);
968 <                colrs_gambs(scanline, xmax);
1152 >                tmap_colrs(scanline, xmax);
1153                  if (maxcolors < 256)
1154                          for (x = 0; x < xmax; x++)
1155 <                                *dp++ = ((long)scanline[x][GRN] *
1155 >                                *dp++ = ((int4)scanline[x][GRN] *
1156                                          maxcolors + maxcolors/2) >> 8;
1157                  else
1158                          for (x = 0; x < xmax; x++)
# Line 976 | Line 1160 | getgrey()                      /* get greyscale data */
1160          }
1161          for (x = 0; x < maxcolors; x++)
1162                  clrtab[x][RED] = clrtab[x][GRN] =
1163 <                        clrtab[x][BLU] = ((long)x*256 + 128)/maxcolors;
1163 >                        clrtab[x][BLU] = ((int4)x*256 + 128)/maxcolors;
1164 >        done_tonemap();
1165   }
1166  
1167  
# Line 986 | Line 1171 | getmapped()                    /* get color-mapped data */
1171                                          /* make sure we can do it first */
1172          if (fname == NULL)
1173                  quiterr("cannot map colors from standard input");
1174 <                                        /* set gamma correction */
1175 <        setcolrgam(gamcor);
1174 >                                        /* initialize tone mapping */
1175 >        make_tonemap();
1176                                          /* make histogram */
1177 <        new_histo();
1177 >        if (new_histo((int4)xmax*ymax) == -1)
1178 >                quiterr("cannot initialize histogram");
1179          for (y = 0; y < ymax; y++) {
1180                  if (getscan(y) < 0)
1181                          break;
1182                  add2icon(y, scanline);
1183 <                if (scale)
998 <                        shiftcolrs(scanline, xmax, scale);
999 <                colrs_gambs(scanline, xmax);
1183 >                tmap_colrs(scanline, xmax);
1184                  cnt_colrs(scanline, xmax);
1185          }
1186                                          /* map pixels */
# Line 1004 | Line 1188 | getmapped()                    /* get color-mapped data */
1188                  quiterr("cannot create color map");
1189          for (y = 0; y < ymax; y++) {
1190                  getscan(y);
1191 <                if (scale)
1008 <                        shiftcolrs(scanline, xmax, scale);
1009 <                colrs_gambs(scanline, xmax);
1191 >                tmap_colrs(scanline, xmax);
1192                  if (dither)
1193                          dith_colrs(ourdata+y*xmax, scanline, xmax);
1194                  else
1195                          map_colrs(ourdata+y*xmax, scanline, xmax);
1196          }
1197 +        done_tonemap();
1198   }
1199  
1200  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines