home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 343_02 / maincp.c < prev    next >
C/C++ Source or Header  |  1992-04-07  |  3KB  |  98 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *       file d:\cips\maincp.c
  5.        *
  6.        *       Functions: This file contains
  7.        *          main
  8.        *
  9.        *       Purpose:
  10.        *          This file contains the main calling
  11.        *          routine for a program which 
  12.        *          cuts pieces from one image and pastes
  13.        *          them into another.
  14.        *
  15.        *       External Calls:
  16.        *          gin.c - get_image_name
  17.        *          numcvrt.c - get_integer
  18.        *                      int_convert
  19.        *          tiff.c - read_tiff_header
  20.        *          cutp.c - cut_image_piece
  21.        *                   paste_image_piece
  22.        *
  23.        *       Modifications:
  24.        *          8 April 1992 - created
  25.        *
  26.        *************************************************/
  27.  
  28. #include "d:\cips\cips.h"
  29.  
  30.  
  31.  
  32. short the_image[ROWS][COLS];
  33. short out_image[ROWS][COLS];
  34.  
  35. main(argc, argv)
  36.    int argc;
  37.    char *argv[];
  38. {
  39.  
  40.    char     name[80], name2[80];
  41.    int      count, length, width;
  42.    struct   tiff_header_struct image_header;
  43.  
  44.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  45.    _setbkcolor(1);
  46.    _settextcolor(7);
  47.    _clearscreen(_GCLEARSCREEN);
  48.  
  49.        /***********************************************
  50.        *
  51.        *       Interpret the command line parameters.
  52.        *
  53.        ************************************************/
  54.  
  55.    if(argc < 3 || argc > 3){
  56.     printf(
  57.      "\n"
  58.      "\n usage: maincp in-file out_file "
  59.      "\n");
  60.     exit(0);
  61.    }
  62.  
  63.    strcpy(name, argv[1]);
  64.    strcpy(name2, argv[2]);
  65.  
  66.    if(does_not_exist(name2)){
  67.       printf("\n\n output file does not exist %s", name2);
  68.       read_tiff_header(name, &image_header);
  69.       round_off_image_size(&image_header,
  70.                            &length, &width);
  71.       image_header.image_length = length*ROWS;
  72.       image_header.image_width  = width*COLS;
  73.       create_allocate_tiff_file(name2, &image_header,
  74.                                 out_image);
  75.    }  /* ends if does_not_exist */
  76.  
  77.        /***********************************************
  78.        *
  79.        *   Cut the three center sections from a
  80.        *   300x300 image and paste them into another 
  81.        *   image.
  82.        *
  83.        ************************************************/
  84.  
  85.    cut_image_piece(name, the_image, 1, 101, 101, 201);
  86.    paste_image_piece(name2, name, the_image, out_image, 
  87.                      1, 101, 101, 201);
  88.  
  89.    cut_image_piece(name, the_image, 101, 101, 201, 201);
  90.    paste_image_piece(name2, name, the_image, out_image, 
  91.                      101, 101, 201, 201);
  92.  
  93.    cut_image_piece(name, the_image, 201, 101, 301, 201);
  94.    paste_image_piece(name2, name, the_image, out_image, 
  95.                      201, 101, 301, 201);
  96.  
  97. }  /* ends main */
  98.