home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Software / ASCENDER / ascendMar8.tar / UMass / BoldtNew / LLVS / extractpieces.c < prev    next >
C/C++ Source or Header  |  1996-01-31  |  3KB  |  94 lines

  1. /*
  2.  * ------------------------------------------------------------------
  3.  * extractpieces.c - Program to extract 512x512 pieces from a huge image
  4.  * Created by Robert Heller on Wed Feb  5 08:51:16 1992
  5.  * ------------------------------------------------------------------
  6.  * Modification History:
  7.  * ------------------------------------------------------------------
  8.  * Contents:
  9.  * ------------------------------------------------------------------
  10.  *  
  11.  * Copyright (c) 1992 by University of Massachuetts
  12.  *     All Rights Reserved
  13.  * 
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include <errno.h>
  18. #include <string.h>
  19. #include <llvs_per_plane.h>
  20.  
  21. extern void extract_plane();
  22.  
  23. main (argc, argv)
  24. int argc;
  25. char* argv[];
  26. {
  27.     static PLANE *inpl, *outpl;
  28.     static PLANE_INFO *inpl_info, *outpl_info;
  29.     static char *inassoc, outfile[256], basename[256], infile[256];
  30.     register char *p;
  31.     register int rowoffset, coloffset, error;
  32.     static LIMITS limits;
  33.  
  34.     if (argc != 2) usage_abort();
  35.     strcpy(infile,argv[1]);
  36.     p = strrchr(infile,'.');
  37.     if (p == NULL) strcat(infile,".plane");
  38.     else if (strchr(p,'/') != NULL) strcat(infile,".plane");
  39.     if (read_plane(&inpl,&inpl_info,&inassoc,infile) < 0) {
  40.         error = errno;
  41.         perror("extractpieces: read_plane");
  42.         fprintf(stderr,"extractpieces: read_plane: could not read in plane %s\n",
  43.             infile);
  44.         exit(error);
  45.     }
  46.     strcpy(basename,infile);
  47.     p = strrchr(basename,'.');
  48.     if (p != NULL) *p = '\0';
  49.     if (new_plane(&outpl,&outpl_info,inpl_info->datatype,inpl_info->level,
  50.               512,512,0,0,&inpl_info->background) < 0) {
  51.         error = errno;
  52.         perror("extractpieces: new_plane");
  53.         fprintf(stderr,"extractpieces: new_plane: could not allocate plane\n");
  54.         exit(error);
  55.     }
  56.     limits.level = inpl_info->level;
  57.     limits.deltarow = 1;    
  58.     limits.deltacol = 1;    
  59.     for (rowoffset = inpl_info->row_location;
  60.          rowoffset < (inpl_info->row_location + inpl_info->row_dimension);
  61.          rowoffset += 512) {
  62.         for (coloffset = inpl_info->column_location;
  63.              coloffset < (inpl_info->column_location +
  64.                   inpl_info->column_dimension);
  65.              coloffset += 512) {
  66.             limits.startrow = rowoffset;
  67.             limits.startcol = coloffset;
  68.             limits.endrow   = rowoffset + 511;
  69.             limits.endcol   = coloffset + 511;
  70.             outpl_info->row_location = rowoffset;
  71.             outpl_info->column_location = coloffset;
  72.             memset(outpl,0,plane_size(outpl_info));
  73.             extract_plane(inpl,inpl_info,outpl,outpl_info,&limits);
  74.             sprintf(outfile,"%sR%dC%d.plane",basename,
  75.                 rowoffset,coloffset);
  76.             if (write_plane(outpl,outpl_info,"NIL",outfile) < 0) {
  77.                 error = errno;
  78.                 perror("extractpieces: write_plane");
  79.                 fprintf(stderr,"extractpieces: write_plane: could not create plane %s\n",
  80.                     outfile);
  81.                 exit(error);
  82.             }
  83.         }
  84.     }
  85. }
  86.  
  87.  
  88. usage_abort()
  89. {
  90.     printf("usage: extractpices planefile\n");
  91.     exit(EINVAL);
  92. }
  93.  
  94.