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.9 by greg, Wed May 13 00:30:13 2020 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  100000
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;
25  
26 < int  dxsize = DXSIZE, dysize = DYSIZE;
26 > int  dxsiz = DXSIZE, dysiz = DYSIZE;
27  
28   int  maxalloc = MAXALLOC;
29  
# 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 */
53 < register char *s;
47 > findtack(char *s)               /* find place to tack on suffix */
48   {
49          while (*s && *s != '.')
50                  s++;
# Line 58 | Line 52 | register char *s;
52   }
53  
54  
55 < main(argc, argv)
56 <
57 < int  argc;
58 < char  **argv;
59 <
55 > int
56 > main(
57 >        int  argc,
58 >        char  **argv
59 > )
60   {
61   FILE  *fp;
68 #ifdef  UNIX
69 FILE  *popen();
70 #endif
62   char  comargs[200], command[300];
63  
73 #ifdef  CPM
74 fixargs("meta2tga", &argc, &argv);
75 #endif
76
64    fout = stdout;
65   progname = *argv++;
66   argc--;
67  
68   condonly = FALSE;
82 #ifdef  CPM
83 conditioned = TRUE;
84 #else
69   conditioned = FALSE;
86 #endif
70  
71   while (argc && **argv == '-')  {
72      switch (*(*argv+1))  {
90 #ifdef  UNIX
73         case 'c':
74            condonly = TRUE;
75            break;
76         case 'r':
77            conditioned = TRUE;
78            break;
97 #endif
79         case 'm':
80            minwidth = atoi(*++argv);
81            argc--;
82            break;
83         case 'x':
84 <          dxsize = atoi(*++argv);
84 >          dxsiz = atoi(*++argv);
85            argc--;
86            break;
87         case 'y':
88 <          dysize = atoi(*++argv);
88 >          dysiz = atoi(*++argv);
89            argc--;
90            break;
91         case 'o':
# Line 142 | Line 123 | char  **argv;
123         argc--;
124         }
125      sprintf(command, XCOM, comargs);
145 #ifdef  UNIX
126      if (condonly)
127         return(system(command));
128      else  {
# Line 153 | Line 133 | char  **argv;
133         if (lineno)
134            nextpage();
135         }
156 #endif
136      }
137  
138   return(0);
139 < }
139 > }
140  
141  
142 <
143 <
165 <
166 <
167 < thispage()              /* rewind current file */
142 > void
143 > thispage(void)          /* rewind current file */
144   {
145      if (lineno)
146          error(USER, "cannot restart page in thispage");
147   }
148  
149  
150 <
151 < initfile()              /* initialize this file */
150 > void
151 > initfile(void)          /* initialize this file */
152   {
153 +    static const unsigned char  cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0,
154 +                        0,200,200, 255,0,255, 179,179,0, 255,255,255};
155      static int  filenum = 0;
178    static unsigned char  cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255,
179                        179,179,0, 255,0,255, 0,200,200, 0,0,0};
156      struct hdStruct  thead;
157 <    register int  i;
157 >    int  i;
158  
159      if (outtack != NULL) {
160          sprintf(outtack, "%d.tga", ++filenum);
# Line 193 | Line 169 | initfile()             /* initialize this file */
169      thead.CMapBits = 24;
170      thead.XOffset = 0;
171      thead.YOffset = 0;
172 <    thead.x = dxsize;
173 <    thead.y = dysize;
172 >    thead.x = dxsiz;
173 >    thead.y = dysiz;
174      thead.dataBits = 8;
175      thead.imType = 0;
176      putthead(&thead, NULL, fout);
# Line 205 | Line 181 | initfile()             /* initialize this file */
181   }
182  
183  
184 <
185 <
210 < nextpage()              /* advance to next page */
211 <
184 > void
185 > nextpage(void)          /* advance to next page */
186   {
187  
188      if (lineno == 0)
189          return;
190      if (fout != NULL) {
191 <        while (lineno < dysize) {
191 >        while (lineno < dysiz) {
192              nextblock();
193              outputblock();
194          }
# Line 226 | Line 200 | nextpage()             /* advance to next page */
200   }
201  
202  
229
203   #define MINRUN  4
204  
205 <
206 < printblock()            /* output scanline block to file */
234 <
205 > void
206 > printblock(void)                /* output scanline block to file */
207   {
208      int  i, c2;
209 <    register unsigned char  *scanline;
210 <    register int  j, beg, cnt;
209 >    unsigned char  *scanline;
210 >    int  j, beg, cnt = 0;
211  
212      if (lineno == 0)
213          initfile();
214 <    for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) {
214 >    for (i = outblock.ybot; i <= outblock.ytop && i < dysiz; i++) {
215          scanline = outblock.cols[i-outblock.ybot];
216          for (j = outblock.xleft; j <= outblock.xright; j += cnt) {
217              for (beg = j; beg <= outblock.xright; beg += cnt) {
# Line 267 | Line 239 | printblock()           /* output scanline block to file */
239   }
240  
241  
242 < putint2(i, fp)                  /* put a 2-byte positive integer */
243 < register int  i;
244 < register FILE   *fp;
242 > void
243 > putint2(                        /* put a 2-byte positive integer */
244 >        int  i,
245 >        FILE    *fp
246 > )
247   {
248          putc(i&0xff, fp);
249          putc(i>>8&0xff, fp);
250   }
251  
252  
253 < putthead(hp, ip, fp)            /* write header to output */
254 < struct hdStruct  *hp;
255 < char  *ip;
256 < register FILE  *fp;
253 > int
254 > putthead(               /* write header to output */
255 >        struct hdStruct  *hp,
256 >        char  *ip,
257 >        FILE  *fp
258 > )
259   {
260          if (ip != NULL)
261                  putc(strlen(ip), fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines