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.2 by schorsch, Fri Aug 1 14:14:24 2003 UTC vs.
Revision 1.8 by greg, Mon Nov 18 22:12:32 2019 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 */
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 FILE  *popen();
64   char  comargs[200], command[300];
65  
66    fout = stdout;
# Line 88 | Line 83 | char  **argv;
83            argc--;
84            break;
85         case 'x':
86 <          dxsize = atoi(*++argv);
86 >          dxsiz = atoi(*++argv);
87            argc--;
88            break;
89         case 'y':
90 <          dysize = atoi(*++argv);
90 >          dysiz = atoi(*++argv);
91            argc--;
92            break;
93         case 'o':
# Line 147 | Line 142 | char  **argv;
142  
143  
144  
145 <
146 <
152 <
153 < 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 179 | Line 176 | initfile()             /* initialize this file */
176      thead.CMapBits = 24;
177      thead.XOffset = 0;
178      thead.YOffset = 0;
179 <    thead.x = dxsize;
180 <    thead.y = dysize;
179 >    thead.x = dxsiz;
180 >    thead.y = dysiz;
181      thead.dataBits = 8;
182      thead.imType = 0;
183      putthead(&thead, NULL, fout);
# Line 192 | Line 189 | initfile()             /* initialize this file */
189  
190  
191  
192 + void
193 + nextpage(void)          /* advance to next page */
194  
196 nextpage()              /* advance to next page */
197
195   {
196  
197      if (lineno == 0)
198          return;
199      if (fout != NULL) {
200 <        while (lineno < dysize) {
200 >        while (lineno < dysiz) {
201              nextblock();
202              outputblock();
203          }
# Line 215 | 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  
219 printblock()            /* output scanline block to file */
220
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();
225 <    for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) {
225 >    for (i = outblock.ybot; i <= outblock.ytop && i < dysiz; i++) {
226          scanline = outblock.cols[i-outblock.ybot];
227          for (j = outblock.xleft; j <= outblock.xright; j += cnt) {
228              for (beg = j; beg <= outblock.xright; beg += cnt) {
# Line 253 | 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