home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "defs.h"
-
- har *progname;
- har *filename;
- ixrect *pr1, *pr2;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- asregion_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- register int i, j;
- int levels;
- int xoffset, yoffset, xsize, ysize;
- colormap_t colormap;
-
- xsize = ysize = 0;
- xoffset = yoffset = -1;
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- while ((gc = getopt(argc, argv, "x:y:X:Y:")) != EOF)
- switch (gc) {
- case 'x':
- xoffset = atoi(optarg);
- break;
- case 'y':
- yoffset = atoi(optarg);
- break;
- case 'X':
- xsize = atoi(optarg);
- break;
- case 'Y':
- ysize = atoi(optarg);
- break;
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [-x xoffset] [-y yoffset] [-X xsize] [-Y ysize] [infile] [outfile]\n", progname);
-
- for (stream = 0; optind < argc; stream++, optind++)
- if (stream < 2 && strcmp(argv[optind], "-") != 0)
- if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
- error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
-
- if ((pr1 = pr_load(stdin, &colormap)) == NULL)
- error(PR_IO_ERR_RASREAD);
-
- if (xsize == 0)
- xsize = pr1->pr_size.x / 2;
-
- if (ysize == 0)
- ysize = pr1->pr_size.y / 2;
-
- if (xoffset == -1)
- xoffset = pr1->pr_size.x / 4;
-
- if (yoffset == -1)
- yoffset = pr1->pr_size.y / 4;
-
- if ((pr2 = pr_region(pr1, xoffset, yoffset, xsize, ysize)) == NULL)
- error("pr_region returned NULL");
-
- pr_dump(pr2, stdout, &colormap, RT_STANDARD, 0);
- }
-