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

Comparing ray/src/meta/meta2tga.c (file contents):
Revision 1.1 by greg, Sat Feb 22 02:07:26 2003 UTC vs.
Revision 1.6 by greg, Wed Feb 4 18:49:24 2004 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *  Program to convert meta-files to Targa 8-bit color-mapped format
6   */
7  
8 + #include  "copyright.h"
9  
10 < #define  MAXALLOC  5000
10 <
11 < #define  DXSIZE  400            /* default x resolution */
12 <
13 < #define  DYSIZE  400            /* default y resolution */
14 <
15 < #define  XCOM  "pexpand +vOCImsp -DP %s | psort +y"
16 <
17 <
18 <
19 <
10 > #include  "rtprocess.h"
11   #include  "meta.h"
21
12   #include  "plot.h"
23
13   #include  "rast.h"
25
14   #include  "targa.h"
15  
16 + #define  MAXALLOC  30000
17 + #define  DXSIZE  400            /* default x resolution */
18 + #define  DYSIZE  400            /* default y resolution */
19 + #define  XCOM  "pexpand +vOCImsp -DP %s | psort +y"
20  
21  
30
22   char  *progname;
23  
24   SCANBLOCK       outblock;
# Line 48 | Line 39 | static int  lineno = 0;
39   static short  condonly = FALSE,
40                conditioned = FALSE;
41  
42 + static int putthead(struct hdStruct  *hp, char  *ip, FILE  *fp);
43 +
44 +
45 +
46   char *
47   findtack(s)                     /* find place to tack on suffix */
48   register char *s;
# Line 58 | Line 53 | register char *s;
53   }
54  
55  
56 < main(argc, argv)
56 > int
57 > main(
58 >        int  argc,
59 >        char  **argv
60 > )
61  
63 int  argc;
64 char  **argv;
65
62   {
63   FILE  *fp;
68 #ifdef  UNIX
69 FILE  *popen();
70 #endif
64   char  comargs[200], command[300];
65  
73 #ifdef  CPM
74 fixargs("meta2tga", &argc, &argv);
75 #endif
76
66    fout = stdout;
67   progname = *argv++;
68   argc--;
69  
70   condonly = FALSE;
82 #ifdef  CPM
83 conditioned = TRUE;
84 #else
71   conditioned = FALSE;
86 #endif
72  
73   while (argc && **argv == '-')  {
74      switch (*(*argv+1))  {
90 #ifdef  UNIX
75         case 'c':
76            condonly = TRUE;
77            break;
78         case 'r':
79            conditioned = TRUE;
80            break;
97 #endif
81         case 'm':
82            minwidth = atoi(*++argv);
83            argc--;
# Line 142 | Line 125 | char  **argv;
125         argc--;
126         }
127      sprintf(command, XCOM, comargs);
145 #ifdef  UNIX
128      if (condonly)
129         return(system(command));
130      else  {
# Line 153 | Line 135 | char  **argv;
135         if (lineno)
136            nextpage();
137         }
156 #endif
138      }
139  
140   return(0);
# Line 161 | Line 142 | char  **argv;
142  
143  
144  
145 <
146 <
166 <
167 < thispage()              /* rewind current file */
145 > void
146 > thispage(void)          /* rewind current file */
147   {
148      if (lineno)
149          error(USER, "cannot restart page in thispage");
150   }
151  
152  
153 <
154 < initfile()              /* initialize this file */
153 > void
154 > initfile(void)          /* initialize this file */
155   {
156      static int  filenum = 0;
157 +    /*
158      static unsigned char  cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255,
159                          179,179,0, 255,0,255, 0,200,200, 0,0,0};
160 +     */
161 +    static unsigned char  cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0,
162 +                        0,200,200, 255,0,255, 179,179,0, 255,255,255};
163      struct hdStruct  thead;
164      register int  i;
165  
# Line 206 | Line 189 | initfile()             /* initialize this file */
189  
190  
191  
192 + void
193 + nextpage(void)          /* advance to next page */
194  
210 nextpage()              /* advance to next page */
211
195   {
196  
197      if (lineno == 0)
# Line 229 | Line 212 | nextpage()             /* advance to next page */
212  
213   #define MINRUN  4
214  
215 + extern void
216 + printblock(void)                /* output scanline block to file */
217  
233 printblock()            /* output scanline block to file */
234
218   {
219      int  i, c2;
220      register unsigned char  *scanline;
221 <    register int  j, beg, cnt;
221 >    register int  j, beg, cnt = 0;
222  
223      if (lineno == 0)
224          initfile();
# Line 267 | Line 250 | printblock()           /* output scanline block to file */
250   }
251  
252  
253 < putint2(i, fp)                  /* put a 2-byte positive integer */
254 < register int  i;
255 < register FILE   *fp;
253 > void
254 > putint2(                        /* put a 2-byte positive integer */
255 >        register int  i,
256 >        register FILE   *fp
257 > )
258   {
259          putc(i&0xff, fp);
260          putc(i>>8&0xff, fp);
261   }
262  
263  
264 < putthead(hp, ip, fp)            /* write header to output */
265 < struct hdStruct  *hp;
266 < char  *ip;
267 < register FILE  *fp;
264 > int
265 > putthead(               /* write header to output */
266 >        struct hdStruct  *hp,
267 >        char  *ip,
268 >        register FILE  *fp
269 > )
270   {
271          if (ip != NULL)
272                  putc(strlen(ip), fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines