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

Comparing ray/src/px/protate.c (file contents):
Revision 1.5 by greg, Tue Jun 26 09:09:35 1990 UTC vs.
Revision 2.4 by greg, Mon Oct 16 11:40:22 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1988 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
5   #endif
6 +
7   /*
8   * prot.c - program to rotate picture file 90 degrees clockwise.
9   *
10   *      2/26/88
11   */
12  
13 < #include <stdio.h>
13 > #include "standard.h"
14  
15   #include "color.h"
16  
17 + #include "resolu.h"
18 +
19 + int     order;                          /* input scanline order */
20   int     xres, yres;                     /* input resolution */
21  
22 + int     correctorder = 0;               /* order correction? */
23 +
24 + #ifdef BIGMEM
25 + char    buf[1<<22];                     /* output buffer */
26 + #else
27   char    buf[1<<20];                     /* output buffer */
28 + #endif
29  
30   int     nrows;                          /* number of rows output at once */
31  
# Line 23 | Line 33 | int    nrows;                          /* number of rows output at once */
33  
34   char    *progname;
35  
36 + #define neworder()      (correctorder ? order : \
37 +                        (order^(order&YMAJOR?YDECR:XDECR)^YMAJOR))
38  
39 +
40   main(argc, argv)
41   int     argc;
42   char    *argv[];
43   {
44 +        static char     picfmt[LPICFMT+1] = PICFMT;
45 +        int     rval;
46          FILE    *fin;
47  
48          progname = argv[0];
49  
50 +        if (argc > 2 && !strcmp(argv[1], "-c")) {
51 +                correctorder++;
52 +                argc--; argv++;
53 +        }
54          if (argc != 2 && argc != 3) {
55 <                fprintf(stderr, "Usage: %s infile [outfile]\n", progname);
55 >                fprintf(stderr, "Usage: %s [-c] infile [outfile]\n", progname);
56                  exit(1);
57          }
58          if ((fin = fopen(argv[1], "r")) == NULL) {
# Line 44 | Line 63 | char   *argv[];
63                  fprintf(stderr, "%s: cannot open\n", argv[2]);
64                  exit(1);
65          }
66 <                                        /* copy header */
67 <        copyheader(fin, stdout);
66 >                                        /* transfer header */
67 >        if ((rval = checkheader(fin, picfmt, stdout)) < 0) {
68 >                fprintf(stderr, "%s: not a Radiance picture\n", progname);
69 >                exit(1);
70 >        }
71 >        if (rval)
72 >                fputformat(picfmt, stdout);
73                                          /* add new header info. */
74 <        printf("%s\n\n", progname);
74 >        printf("%s%s\n\n", progname, correctorder?" -c":"");
75                                          /* get picture size */
76 <        if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
76 >        if ((order = fgetresolu(&xres, &yres, fin)) < 0) {
77                  fprintf(stderr, "%s: bad picture size\n", progname);
78                  exit(1);
79          }
80                                          /* write new picture size */
81 <        fputresolu(YMAJOR|YDECR, yres, xres, stdout);
81 >        fputresolu(neworder(), yres, xres, stdout);
82                                          /* compute buffer capacity */
83          nrows = sizeof(buf)/sizeof(COLR)/yres;
84          rotate(fin);                    /* rotate the image */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines