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

Comparing ray/src/px/ra_t8.c (file contents):
Revision 2.11 by greg, Tue May 13 17:58:33 2003 UTC vs.
Revision 2.13 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   */
10  
11   #include  <stdio.h>
12 <
12 > #include  <string.h>
13   #include  <time.h>
14 + #include  <math.h>
15  
16 + #include  "platform.h"
17 + #include  "rtmisc.h"
18   #include  "color.h"
16
19   #include  "resolu.h"
20 <
20 > #include  "clrtab.h"
21   #include  "targa.h"
22  
21 #ifdef MSDOS
22 #include  <fcntl.h>
23 #endif
23  
25 #include  <math.h>
26
27 #ifndef  BSD
28 #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
29 #endif
30
24   #define  goodpic(h)     (my_imType(h) && my_mapType(h))
25   #define  my_imType(h)   (((h)->dataType==IM_CMAP || (h)->dataType==IM_CCMAP) \
26                                  && (h)->dataBits==8 && (h)->imType==0)
# Line 37 | Line 30 | static const char      RCSid[] = "$Id$";
30   #define  taralloc(h)    (BYTE *)emalloc((h)->x*(h)->y)
31  
32   BYTE  clrtab[256][3];
40
33   extern int      samplefac;
42
43 extern char     *ecalloc(), *emalloc();
44
45 extern long  ftell();
46
34   double  gamv = 2.2;                     /* gamv correction */
48
35   int  bradj = 0;                         /* brightness adjustment */
50
36   char  *progname;
52
37   char  errmsg[128];
54
38   COLR    *inl;
56
39   BYTE    *tarData;
58
40   int  xmax, ymax;
41  
42 + static int getint2(FILE *fp);
43 + static void putint2(int  i, FILE        *fp);
44 + static void quiterr(char  *err);
45 + static int getthead(struct hdStruct      *hp, char  *ip, FILE  *fp);
46 + static int putthead(struct hdStruct      *hp, char  *ip, FILE  *fp);
47 + static int getrhead(struct hdStruct  *h, FILE  *fp);
48 + static void tg2ra(struct hdStruct        *hp);
49 + static void getmapped(int  nc, int  dith);
50 + static void getgrey(int  nc);
51 + static void writetarga(struct hdStruct   *h, BYTE  *d, FILE  *fp);
52 + static void readtarga(struct hdStruct    *h, BYTE  *data, FILE  *fp);
53  
54 < main(argc, argv)
55 < int  argc;
56 < char  *argv[];
54 >
55 > int
56 > main(
57 >        int  argc,
58 >        char  *argv[]
59 > )
60   {
61          struct hdStruct  head;
62          int  dither = 1;
# Line 69 | Line 64 | char  *argv[];
64          int  ncolors = 256;
65          int  greyscale = 0;
66          int  i;
67 < #ifdef MSDOS
68 <        extern int  _fmode;
69 <        _fmode = O_BINARY;
75 <        setmode(fileno(stdin), O_BINARY);
76 <        setmode(fileno(stdout), O_BINARY);
77 < #endif
67 >        SET_DEFAULT_BINARY();
68 >        SET_FILE_BINARY(stdin);
69 >        SET_FILE_BINARY(stdout);
70          progname = argv[0];
71          samplefac = 0;
72  
# Line 160 | Line 152 | userr:
152   }
153  
154  
155 < int
156 < getint2(fp)                     /* get a 2-byte positive integer */
157 < register FILE   *fp;
155 > static int
156 > getint2(                        /* get a 2-byte positive integer */
157 >        register FILE   *fp
158 > )
159   {
160          register int  b1, b2;
161  
# Line 173 | Line 166 | register FILE  *fp;
166   }
167  
168  
169 < putint2(i, fp)                  /* put a 2-byte positive integer */
170 < register int  i;
171 < register FILE   *fp;
169 > static void
170 > putint2(                        /* put a 2-byte positive integer */
171 >        register int  i,
172 >        register FILE   *fp
173 > )
174   {
175          putc(i&0xff, fp);
176          putc(i>>8&0xff, fp);
177   }
178  
179  
180 < quiterr(err)            /* print message and exit */
181 < char  *err;
180 > static void
181 > quiterr(                /* print message and exit */
182 >        char  *err
183 > )
184   {
185          if (err != NULL) {
186                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 209 | Line 206 | int code;
206   }
207  
208  
209 < getthead(hp, ip, fp)            /* read header from input */
210 < struct hdStruct  *hp;
211 < char  *ip;
212 < register FILE  *fp;
209 > static int
210 > getthead(               /* read header from input */
211 >        struct hdStruct  *hp,
212 >        char  *ip,
213 >        register FILE  *fp
214 > )
215   {
216          int     nidbytes;
217  
# Line 242 | Line 241 | register FILE  *fp;
241   }
242  
243  
244 < putthead(hp, ip, fp)            /* write header to output */
245 < struct hdStruct  *hp;
246 < char  *ip;
247 < register FILE  *fp;
244 > static int
245 > putthead(               /* write header to output */
246 >        struct hdStruct  *hp,
247 >        char  *ip,
248 >        register FILE  *fp
249 > )
250   {
251          if (ip != NULL)
252                  putc(strlen(ip), fp);
# Line 270 | Line 271 | register FILE  *fp;
271   }
272  
273  
274 < getrhead(h, fp)                 /* load RADIANCE input file header */
275 < register struct hdStruct  *h;
276 < FILE  *fp;
274 > static int
275 > getrhead(                       /* load RADIANCE input file header */
276 >        register struct hdStruct  *h,
277 >        FILE  *fp
278 > )
279   {
280                                          /* get header info. */
281          if (checkheader(fp, COLRFMT, NULL) < 0 ||
# Line 300 | Line 303 | FILE  *fp;
303   }
304  
305  
306 < tg2ra(hp)                       /* targa file to RADIANCE file */
307 < struct hdStruct  *hp;
306 > static void
307 > tg2ra(                  /* targa file to RADIANCE file */
308 >        struct hdStruct  *hp
309 > )
310   {
311          union {
312                  BYTE  c3[256][3];
# Line 349 | Line 354 | struct hdStruct         *hp;
354   }
355  
356  
357 < getmapped(nc, dith)             /* read in and quantize image */
358 < int  nc;                /* number of colors to use */
359 < int  dith;              /* use dithering? */
357 > static void
358 > getmapped(              /* read in and quantize image */
359 >        int  nc,                /* number of colors to use */
360 >        int  dith               /* use dithering? */
361 > )
362   {
363          long  fpos;
364          register int  y;
# Line 397 | Line 404 | int  dith;             /* use dithering? */
404   }
405  
406  
407 < getgrey(nc)                     /* read in and convert to greyscale image */
408 < int  nc;                /* number of colors to use */
407 > static void
408 > getgrey(                        /* read in and convert to greyscale image */
409 >        int  nc         /* number of colors to use */
410 > )
411   {
412          int  y;
413          register BYTE  *dp;
# Line 429 | Line 438 | int  nc;               /* number of colors to use */
438   }
439  
440  
441 < writetarga(h, d, fp)            /* write out targa data */
442 < struct hdStruct  *h;
443 < BYTE  *d;
444 < FILE  *fp;
441 > static void
442 > writetarga(             /* write out targa data */
443 >        struct hdStruct  *h,
444 >        BYTE  *d,
445 >        FILE  *fp
446 > )
447   {
448          register int  i, j;
449  
# Line 448 | Line 459 | FILE  *fp;
459   }
460  
461  
462 < readtarga(h, data, fp)          /* read in targa data */
463 < struct hdStruct  *h;
464 < BYTE  *data;
465 < FILE  *fp;
462 > static void
463 > readtarga(              /* read in targa data */
464 >        struct hdStruct  *h,
465 >        BYTE  *data,
466 >        FILE  *fp
467 > )
468   {
469          register int  cnt, c;
470          register BYTE   *dp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines