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