--- ray/src/px/ra_gif.c 1994/03/30 14:24:52 2.1 +++ ray/src/px/ra_gif.c 2003/07/27 22:12:03 2.10 @@ -1,26 +1,19 @@ -/* Copyright (c) 1994 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ra_gif.c,v 2.10 2003/07/27 22:12:03 schorsch Exp $"; #endif - /* * Convert from Radiance picture file to Compuserve GIF. * Currently, we don't know how to get back. */ #include +#include +#include +#include "platform.h" #include "color.h" - #include "resolu.h" -#ifdef MSDOS -#include -#endif - -#include - #define MAXCOLORS 256 int rmap[MAXCOLORS]; @@ -33,11 +26,14 @@ extern long ftell(); long picstart; -extern BYTE clrtab[][3]; +BYTE clrtab[256][3]; +extern int samplefac; + extern int getgifpix(); COLR *scanln; +BYTE *pixscan; int xmax, ymax; /* picture size */ @@ -45,8 +41,12 @@ double gamv = 2.2; /* gamma correction */ int greyscale = 0; /* convert to B&W? */ +int dither = 1; /* dither colors? */ + int bradj = 0; /* brightness adjustment */ +int ncolors = 0; /* number of colors requested */ + char *progname; @@ -54,16 +54,13 @@ main(argc, argv) int argc; char *argv[]; { - int ncolors = 0; int bitsperpix; int i; -#ifdef MSDOS - extern int _fmode; - _fmode = O_BINARY; - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); progname = argv[0]; + samplefac = 0; for (i = 1; i < argc; i++) if (argv[i][0] == '-') @@ -74,6 +71,9 @@ char *argv[]; case 'b': greyscale = 1; break; + case 'd': + dither = !dither; + break; case 'c': ncolors = atoi(argv[++i]); break; @@ -82,6 +82,9 @@ char *argv[]; goto userr; bradj = atoi(argv[++i]); break; + case 'n': + samplefac = atoi(argv[++i]); + break; default: goto userr; } @@ -115,7 +118,7 @@ char *argv[]; /* set up gamma correction */ setcolrgam(gamv); /* figure out the bits per pixel */ - if (ncolors < 2 | ncolors > MAXCOLORS) + if ((ncolors < 2) | (ncolors > MAXCOLORS)) ncolors = MAXCOLORS; for (bitsperpix = 1; ncolors > 1<>8); + if (pixscan != NULL) + return(pixscan[x]); + return(samplefac ? neu_map_pixel(scanln[x]) : map_pixel(scanln[x])); }