home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011109a < prev    next >
Text File  |  1992-09-02  |  4KB  |  130 lines

  1.        /***********************************************
  2.        *
  3.        *       file d:\cips\mainr.c
  4.        *
  5.        *       Functions: This file contains
  6.        *          main
  7.        *
  8.        *       Purpose:
  9.        *          This file contains the main calling
  10.        *          routine for a program which rotates an
  11.        *          entire 300x300 image by 90
  12.        *          degrees.
  13.        *
  14.        *       External Calls:
  15.        *          gin.c - get_image_name
  16.        *          numcvrt.c - get_integer
  17.        *                      int_convert
  18.        *          tiff.c - read_tiff_header
  19.        *          rotate.c - rotate_flip_image_array
  20.        *
  21.        *       Modifications:
  22.        *          7 April 1992 - created
  23.        *
  24.        *************************************************/
  25.  
  26. #include "d:\cips\cips.h"
  27.  
  28.  
  29.  
  30. short the_image[ROWS][COLS];
  31. short out_image[ROWS][COLS];
  32.  
  33. main(argc, argv)
  34.    int argc;
  35.    char *argv[];
  36. {
  37.  
  38.    char     name[80], name2[80];
  39.    int      count, length, width;
  40.    struct   tiff_header_struct image_header;
  41.  
  42.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  43.    _setbkcolor(1);
  44.    _settextcolor(7);
  45.    _clearscreen(_GCLEARSCREEN);
  46.        /***********************************************
  47.        *
  48.        *       Interpret the command line parameters.
  49.        *
  50.        ************************************************/
  51.  
  52.    if(argc < 3 || argc > 3){
  53.     printf(
  54.      "\n"
  55.      "\n usage: mainr in-file out_file "
  56.      "\n");
  57.     exit(0);
  58.    }
  59.  
  60.    strcpy(name, argv[1]);
  61.    strcpy(name2, argv[2]);
  62.  
  63.    if(does_not_exist(name2)){
  64.       printf("\n\n output file does not exist %s", name2);
  65.       read_tiff_header(name, &image_header);
  66.       round_off_image_size(&image_header,
  67.                            &length, &width);
  68.       image_header.image_length = length*ROWS;
  69.       image_header.image_width  = width*COLS;
  70.       create_allocate_tiff_file(name2, &image_header,
  71.                                 out_image);
  72.    }  /* ends if does_not_exist */
  73.  
  74.        /***********************************************
  75.        *
  76.        *   Read, rotate, and write each ROWSxCOLS array
  77.        *   in the input image.  Write them to the new
  78.        *   locations in the output image.
  79.        *
  80.        ************************************************/
  81.  
  82.    count = 1;
  83.  
  84.    printf(" %d", count++);
  85.    rotate_flip_image_array(name, name2, the_image,
  86.                       out_image, 1, 1, 101, 101,
  87.                       1, 201, 101, 301, 1);
  88.  
  89.    printf(" %d", count++);
  90.    rotate_flip_image_array(name, name2, the_image,
  91.                       out_image, 1, 101, 101, 201,
  92.                       101, 201, 201, 301, 1);
  93.  
  94.    printf(" %d", count++);
  95.    rotate_flip_image_array(name, name2, the_image,
  96.                       out_image, 1, 201, 101, 301,
  97.                       201, 201, 301, 301, 1);
  98.  
  99.    printf(" %d", count++);
  100.    rotate_flip_image_array(name, name2, the_image,
  101.                       out_image, 101, 1, 201, 101,
  102.                       1, 101, 101, 201, 1);
  103.  
  104.    printf(" %d", count++);
  105.    rotate_flip_image_array(name, name2, the_image,
  106.                       out_image, 101, 101, 201, 201,
  107.                       101, 101, 201, 201, 1);
  108.  
  109.    printf(" %d", count++);
  110.    rotate_flip_image_array(name, name2, the_image,
  111.                       out_image, 101, 201, 201, 301,
  112.                       201, 101, 301, 201, 1);
  113.  
  114.    printf(" %d", count++);
  115.    rotate_flip_image_array(name, name2, the_image,
  116.                       out_image, 201, 1, 301, 101,
  117.                       1, 1, 101, 101, 1);
  118.  
  119.    printf(" %d", count++);
  120.    rotate_flip_image_array(name, name2, the_image,
  121.                       out_image, 201, 101, 301, 201,
  122.                       101, 1, 201, 101, 1);
  123.  
  124.    printf(" %d", count++);
  125.    rotate_flip_image_array(name, name2, the_image,
  126.                       out_image, 201, 201, 301, 301,
  127.                       201, 1, 301, 101, 1);
  128.  
  129. }  /* ends main  */
  130.