59 |
|
#define unguard() |
60 |
|
#endif |
61 |
|
|
62 |
– |
extern char *strerror(); |
63 |
– |
|
62 |
|
/* rpict command */ |
63 |
|
char *rpargv[128] = {"rpict", "-S", "1"}; |
64 |
|
int rpargc = 3; |
153 |
|
++i; |
154 |
|
continue; |
155 |
|
} |
156 |
+ |
if (argv[i][2] == 'X') { |
157 |
+ |
fprintf(stderr, "%s: -pXYZ unsupported\n", |
158 |
+ |
argv[0]); |
159 |
+ |
++i; |
160 |
+ |
continue; |
161 |
+ |
} |
162 |
+ |
if (argv[i][2] == 'c') { |
163 |
+ |
fprintf(stderr, "%s: -pc unsupported\n", |
164 |
+ |
argv[0]); |
165 |
+ |
i += 9; |
166 |
+ |
continue; |
167 |
+ |
} |
168 |
|
if (argv[i][2] != 'a' || argv[i][3]) |
169 |
|
break; |
170 |
|
pixaspect = atof(argv[++i]); |
171 |
|
continue; |
172 |
+ |
case 'S': |
173 |
+ |
fprintf(stderr, "%s: -S unsupported\n", argv[0]); |
174 |
+ |
i++; |
175 |
+ |
continue; |
176 |
|
case 'T': /* time limit (hours) */ |
177 |
|
if (argv[i][2]) |
178 |
|
break; |
300 |
|
sprintf(vrbuf, "%d", vres); |
301 |
|
rpargv[rpargc++] = "-y"; rpargv[rpargc++] = vrbuf; |
302 |
|
rpargv[rpargc++] = "-pa"; rpargv[rpargc++] = "0"; |
303 |
+ |
rpargv[rpargc++] = "-pm"; rpargv[rpargc++] = "0"; |
304 |
|
rpargv[rpargc++] = av[ac-1]; |
305 |
|
rpargv[rpargc] = NULL; |
306 |
|
/* open output file */ |
313 |
|
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
314 |
|
fputs(VIEWSTR, fp); |
315 |
|
fprintview(&ourview, fp); |
316 |
< |
putc('\n', fp); |
316 |
> |
fputc('\n', fp); |
317 |
|
fputnow(fp); |
318 |
|
if (pixaspect < .99 || pixaspect > 1.01) |
319 |
|
fputaspect(pixaspect, fp); |
320 |
+ |
fputprims(stdprims, fp); |
321 |
|
fputformat(COLRFMT, fp); |
322 |
< |
putc('\n', fp); |
322 |
> |
fputc('\n', fp); |
323 |
|
fprtresolu(hres*hmult, vres*vmult, fp); |
324 |
|
} else if ((outfd = open(outfile, O_RDWR)) >= 0) { |
325 |
|
dolock(outfd, F_RDLCK); |
477 |
|
static void |
478 |
|
rpiece(void) /* render picture piece by piece */ |
479 |
|
{ |
480 |
+ |
char *err; |
481 |
|
VIEW pview; |
482 |
|
int xorg, yorg; |
466 |
– |
/* compute view parameters */ |
467 |
– |
pview = ourview; |
468 |
– |
switch (ourview.type) { |
469 |
– |
case VT_PER: |
470 |
– |
pview.horiz = (2.*180./PI)*atan( |
471 |
– |
tan((PI/180./2.)*ourview.horiz)/hmult ); |
472 |
– |
pview.vert = (2.*180./PI)*atan( |
473 |
– |
tan((PI/180./2.)*ourview.vert)/vmult ); |
474 |
– |
break; |
475 |
– |
case VT_PAR: |
476 |
– |
case VT_ANG: |
477 |
– |
pview.horiz = ourview.horiz / hmult; |
478 |
– |
pview.vert = ourview.vert / vmult; |
479 |
– |
break; |
480 |
– |
case VT_CYL: |
481 |
– |
pview.horiz = ourview.horiz / hmult; |
482 |
– |
pview.vert = (2.*180./PI)*atan( |
483 |
– |
tan((PI/180./2.)*ourview.vert)/vmult ); |
484 |
– |
break; |
485 |
– |
case VT_HEM: |
486 |
– |
pview.horiz = (2.*180./PI)*asin( |
487 |
– |
sin((PI/180./2.)*ourview.horiz)/hmult ); |
488 |
– |
pview.vert = (2.*180./PI)*asin( |
489 |
– |
sin((PI/180./2.)*ourview.vert)/vmult ); |
490 |
– |
break; |
491 |
– |
case VT_PLS: |
492 |
– |
pview.horiz = sin((PI/180./2.)*ourview.horiz) / |
493 |
– |
(1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult; |
494 |
– |
pview.horiz *= pview.horiz; |
495 |
– |
pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) / |
496 |
– |
(1. + pview.horiz)); |
497 |
– |
pview.vert = sin((PI/180./2.)*ourview.vert) / |
498 |
– |
(1.0 + cos((PI/180./2.)*ourview.vert)) / vmult; |
499 |
– |
pview.vert *= pview.vert; |
500 |
– |
pview.vert = (2.*180./PI)*acos((1. - pview.vert) / |
501 |
– |
(1. + pview.vert)); |
502 |
– |
break; |
503 |
– |
default: |
504 |
– |
fprintf(stderr, "%s: unknown view type '-vt%c'\n", |
505 |
– |
progname, ourview.type); |
506 |
– |
exit(cleanup(1)); |
507 |
– |
} |
483 |
|
/* render each piece */ |
484 |
|
while (nextpiece(&xorg, &yorg)) { |
485 |
< |
pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1); |
486 |
< |
pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1); |
485 |
> |
pview = ourview; |
486 |
> |
err = cropview(&pview, (double)xorg/hmult, (double)yorg/vmult, |
487 |
> |
(xorg+1.)/hmult, (yorg+1.)/vmult); |
488 |
> |
if (err != NULL) { |
489 |
> |
fprintf(stderr, "%s: %s\n", progname, err); |
490 |
> |
exit(cleanup(1)); |
491 |
> |
} |
492 |
|
fputs(VIEWSTR, torp); |
493 |
|
fprintview(&pview, torp); |
494 |
< |
putc('\n', torp); |
494 |
> |
fputc('\n', torp); |
495 |
|
fflush(torp); /* assigns piece to rpict */ |
496 |
|
putpiece(xorg, yorg); /* place piece in output */ |
497 |
|
} |
569 |
|
if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0) |
570 |
|
filerr("seek"); |
571 |
|
if (hmult == 1) { |
572 |
< |
if (writebuf(outfd, (char *)pbuf, |
572 |
> |
if (writebuf(outfd, pbuf, |
573 |
|
vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR)) |
574 |
|
filerr("write"); |
575 |
|
} else |
576 |
|
for (y = 0; y < vr; y++) { |
577 |
< |
if (writebuf(outfd, (char *)(pbuf+y*hr), |
577 |
> |
if (writebuf(outfd, pbuf+y*hr, |
578 |
|
hr*sizeof(COLR)) != hr*sizeof(COLR)) |
579 |
|
filerr("write"); |
580 |
|
if (y < vr-1 && lseek(outfd, |