27 |
|
|
28 |
|
#ifndef BSD |
29 |
|
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
30 |
– |
extern char *memcpy(); |
30 |
|
#endif |
31 |
|
|
32 |
|
#define goodpic(h) (my_imType(h) && my_mapType(h)) |
37 |
|
|
38 |
|
#define taralloc(h) (BYTE *)emalloc((h)->x*(h)->y) |
39 |
|
|
40 |
< |
extern BYTE clrtab[][3]; |
40 |
> |
BYTE clrtab[256][3]; |
41 |
|
|
42 |
+ |
extern int samplefac; |
43 |
+ |
|
44 |
|
extern char *ecalloc(), *emalloc(); |
45 |
|
|
46 |
|
extern long ftell(); |
77 |
|
setmode(fileno(stdout), O_BINARY); |
78 |
|
#endif |
79 |
|
progname = argv[0]; |
80 |
+ |
samplefac = 0; |
81 |
|
|
82 |
|
for (i = 1; i < argc; i++) |
83 |
|
if (argv[i][0] == '-') |
102 |
|
case 'c': |
103 |
|
ncolors = atoi(argv[++i]); |
104 |
|
break; |
105 |
+ |
case 'n': |
106 |
+ |
samplefac = atoi(argv[++i]); |
107 |
+ |
break; |
108 |
|
default: |
109 |
|
goto userr; |
110 |
|
} |
153 |
|
quiterr(NULL); |
154 |
|
userr: |
155 |
|
fprintf(stderr, |
156 |
< |
"Usage: %s [-d][-c ncolors][-b][-g gamv][-e +/-stops] input [output]\n", |
156 |
> |
"Usage: %s [-d][-n samp][-c ncolors][-b][-g gamv][-e +/-stops] input [output]\n", |
157 |
|
progname); |
158 |
|
fprintf(stderr, " Or: %s -r [-g gamv][-e +/-stops] [input [output]]\n", |
159 |
|
progname); |
357 |
|
|
358 |
|
setcolrgam(gamv); |
359 |
|
fpos = ftell(stdin); |
360 |
< |
new_histo(); /* build histogram */ |
360 |
> |
if ((samplefac ? neu_init(xmax*ymax) : new_histo(xmax*ymax)) == -1) |
361 |
> |
quiterr("cannot initialized histogram"); |
362 |
|
for (y = ymax-1; y >= 0; y--) { |
363 |
|
if (freadcolrs(inl, xmax, stdin) < 0) |
364 |
|
quiterr("error reading Radiance input"); |
365 |
|
if (bradj) |
366 |
|
shiftcolrs(inl, xmax, bradj); |
367 |
|
colrs_gambs(inl, xmax); |
368 |
< |
cnt_colrs(inl, xmax); |
368 |
> |
if (samplefac) |
369 |
> |
neu_colrs(inl, xmax); |
370 |
> |
else |
371 |
> |
cnt_colrs(inl, xmax); |
372 |
|
} |
373 |
|
if (fseek(stdin, fpos, 0) == EOF) |
374 |
|
quiterr("Radiance input must be from a file"); |
375 |
< |
new_clrtab(nc); /* map colors */ |
375 |
> |
if (samplefac) /* map colors */ |
376 |
> |
neu_clrtab(nc); |
377 |
> |
else |
378 |
> |
new_clrtab(nc); |
379 |
|
for (y = ymax-1; y >= 0; y--) { |
380 |
|
if (freadcolrs(inl, xmax, stdin) < 0) |
381 |
|
quiterr("error reading Radiance input"); |
382 |
|
if (bradj) |
383 |
|
shiftcolrs(inl, xmax, bradj); |
384 |
|
colrs_gambs(inl, xmax); |
385 |
< |
if (dith) |
386 |
< |
dith_colrs(tarData+y*xmax, inl, xmax); |
385 |
> |
if (samplefac) |
386 |
> |
if (dith) |
387 |
> |
neu_dith_colrs(tarData+y*xmax, inl, xmax); |
388 |
> |
else |
389 |
> |
neu_map_colrs(tarData+y*xmax, inl, xmax); |
390 |
|
else |
391 |
< |
map_colrs(tarData+y*xmax, inl, xmax); |
391 |
> |
if (dith) |
392 |
> |
dith_colrs(tarData+y*xmax, inl, xmax); |
393 |
> |
else |
394 |
> |
map_colrs(tarData+y*xmax, inl, xmax); |
395 |
|
} |
396 |
|
} |
397 |
|
|