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

Comparing ray/src/px/ra_gif.c (file contents):
Revision 2.1 by greg, Wed Mar 30 14:24:52 1994 UTC vs.
Revision 2.4 by greg, Fri Jun 10 12:51:27 1994 UTC

# Line 33 | Line 33 | extern long  ftell();
33  
34   long  picstart;
35  
36 < extern BYTE  clrtab[][3];
36 > BYTE  clrtab[256][3];
37  
38 + extern int  samplefac;
39 +
40   extern int  getgifpix();
41  
42   COLR    *scanln;
43 + BYTE    *pixscan;
44  
45   int  xmax, ymax;                        /* picture size */
46  
# Line 45 | Line 48 | double gamv = 2.2;                     /* gamma correction */
48  
49   int  greyscale = 0;                     /* convert to B&W? */
50  
51 + int  dither = 1;                        /* dither colors? */
52 +
53   int  bradj = 0;                         /* brightness adjustment */
54  
55   char  *progname;
# Line 64 | Line 69 | char  *argv[];
69          setmode(fileno(stdout), O_BINARY);
70   #endif
71          progname = argv[0];
72 +        samplefac = 0;
73  
74          for (i = 1; i < argc; i++)
75                  if (argv[i][0] == '-')
# Line 74 | Line 80 | char  *argv[];
80                          case 'b':
81                                  greyscale = 1;
82                                  break;
83 +                        case 'd':
84 +                                dither = !dither;
85 +                                break;
86                          case 'c':
87                                  ncolors = atoi(argv[++i]);
88                                  break;
# Line 82 | Line 91 | char  *argv[];
91                                          goto userr;
92                                  bradj = atoi(argv[++i]);
93                                  break;
94 +                        case 'n':
95 +                                samplefac = atoi(argv[++i]);
96 +                                break;
97                          default:
98                                  goto userr;
99                          }
# Line 149 | Line 161 | int  y;
161                  if (freadcolrs(scanln, xmax, stdin) < 0) {
162                          fprintf(stderr, "%s: error reading picture (y==%d)\n",
163                                          progname, ymax-1-y);
164 +                        exit(1);
165                  }
166          while (++currow < y);
167          if (bradj)
168                  shiftcolrs(scanln, xmax, bradj);
169          colrs_gambs(scanln, xmax);
170 +        if (pixscan != NULL)
171 +                if (samplefac)
172 +                        neu_dith_colrs(pixscan, scanln, xmax);
173 +                else
174 +                        dith_colrs(pixscan, scanln, xmax);
175   }
176  
177  
# Line 162 | Line 180 | int    nc;
180   {
181          register int    i;
182  
183 <        new_histo();
183 >        if ((samplefac ? neu_init(xmax*ymax) : new_histo(xmax*ymax)) == -1)
184 >                goto memerr;
185          for (i = 0; i < ymax; i++) {
186                  getrow(i);
187 <                cnt_colrs(scanln, xmax);
187 >                if (samplefac)
188 >                        neu_colrs(scanln, xmax);
189 >                else
190 >                        cnt_colrs(scanln, xmax);
191          }
192 <        new_clrtab(nc);
192 >        if (samplefac)
193 >                neu_clrtab(nc);
194 >        else
195 >                new_clrtab(nc);
196          for (i = 0; i < nc; i++) {
197                  rmap[i] = clrtab[i][RED];
198                  gmap[i] = clrtab[i][GRN];
199                  bmap[i] = clrtab[i][BLU];
200          }
201 +        if (dither && (pixscan = (BYTE *)malloc(xmax)) == NULL)
202 +                goto memerr;
203 +        return;
204 + memerr:
205 +        fprintf(stderr, "%s: out of memory\n", progname);
206 +        exit(1);
207   }
208  
209  
# Line 198 | Line 229 | int  x, y;
229          getrow(y);
230          if (greyscale)
231                  return(normbright(scanln[x]));
232 <        return(map_pixel(scanln[x]));
232 >        if (pixscan != NULL)
233 >                return(pixscan[x]);
234 >        return(samplefac ? neu_map_pixel(scanln[x]) : map_pixel(scanln[x]));
235   }
236  
237  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines