home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_05 / 9n05118a < prev    next >
Text File  |  1991-03-18  |  5KB  |  202 lines

  1.  
  2.  /***********************************************
  3.  *
  4.  *  file d:\cips\cips.c
  5.  *
  6.  *  Functions: This file contains
  7.  *      main
  8.  *      clear_text_screen
  9.  *      show_menu
  10.  *      show_image
  11.  *
  12.  *  External Calls:
  13.  *    numcvrt.c - get_integer
  14.  *    gin.c - get_image_name
  15.  *    rtiff.c - read_tiff_image
  16.  *    tiff.c - read_tiff_header
  17.  *    rstring.c - read_string
  18.  *    display.c - display_image
  19.  *           display_menu_for_display_image
  20.  *    pi.c - print_image
  21.  *
  22.  *  Modifications:
  23.  *     26 June 1990 - created
  24.  *
  25.  *************************************************/
  26.  
  27. #include "d:\cips\cips.h"
  28.  
  29.  
  30. short the_image[ROWS][COLS];
  31. short out_image[ROWS][COLS];
  32.  
  33. main()
  34. {
  35.  
  36.  char    color_transform[80],
  37.          monitor_type[80], 
  38.          name[80],
  39.          name2[80],
  40.          rep[80];
  41.  
  42.  int     color,
  43.          display_colors,
  44.          file_d,
  45.          first_element,
  46.          first_line,
  47.          i,
  48.          ie,
  49.          il,
  50.          image_colors,
  51.          invert,
  52.          j,
  53.          le,
  54.          ll,
  55.          not_finished,
  56.          response;
  57.  
  58.  long    mean_of_pixels;
  59.  struct  tiff_header_struct image_header;
  60.  
  61.  clear_text_screen();
  62.  
  63.  not_finished =  1;
  64.  response   = 99;
  65.  
  66.  il    = 1;
  67.  ie    = 1;
  68.  ll         = ROWS+1;
  69.  le         = COLS+1;
  70.  
  71.  display_colors = 16;
  72.  image_colors   = 16;
  73.  invert         =  0;
  74.  strcpy(color_transform, "Straight mode");
  75.  strcpy(monitor_type, "VGA");
  76.  
  77.  strcpy(name, "d:/pix/adam256.tif");
  78.  
  79. while(not_finished){
  80.    show_menu();
  81.  
  82.    get_integer(&response);
  83.  
  84.    switch (response){
  85.  
  86.    case 1:/* display image header */
  87.        get_image_name(name);
  88.        read_tiff_header(name, &image_header);
  89.        printf("\n\nCIPS> The image header is:");
  90.        printf("\n\t\twidth=%ld length=%ld  start=%ld  bits=%ld",
  91.            image_header.image_width,
  92.            image_header.image_length,
  93.            image_header.strip_offset,
  94.            image_header.bits_per_pixel);
  95.        printf("\nCIPS> Hit Enter to continue");
  96.        read_string(rep);
  97.        break;
  98.  
  99.    case 2:/* display image numbers */
  100.        get_image_name(name);
  101.        get_parameters(&il, &ie, &ll, &le);
  102.        read_tiff_image(name, the_image, il, ie, ll, le);
  103.        show_image(the_image, il, ie);
  104.        break;
  105.  
  106.    case 3:   /* print image numbers */
  107.        get_image_name(name);
  108.        get_parameters(&il, &ie, &ll, &le);
  109.        read_tiff_image(name, the_image, il, ie, ll, le);
  110.        print_image(the_image, name, 1, 1, 1, 100, 18,
  111.                 il, ie);
  112.        break;
  113.  
  114.    case 4:   /* display image */
  115.        get_image_name(name);
  116.        read_tiff_header(name, &image_header);
  117.        get_parameters(&il, &ie, &ll, &le);
  118.        display_menu_for_display_image(&image_colors,
  119.              &display_colors, &invert,
  120.              color_transform, monitor_type);
  121.        display_image(name, the_image, il, ie,
  122.              ll, le, &image_header, monitor_type,
  123.              color_transform, invert,
  124.              image_colors, display_colors);
  125.        break;
  126.  
  127.    case 20:  /* exit system */
  128.        not_finished = 0;
  129.        break;
  130.  
  131.    default:
  132.        printf("\nCould not understand response, try again");
  133.        break;
  134.  
  135.      }               /* ends switch response          */
  136.   }               /* ends while not finished */
  137. }               /* ends main                  */
  138.  
  139. /******************************************************
  140. *   clear_text_screen()
  141. *
  142. *   This calls Microsoft C functions to clear the text
  143. *   screen and set a blue background with gray text.
  144. *******************************************************/
  145.  
  146. clear_text_screen()
  147. {
  148.    _setvideomode(_TEXTC80);      /* MSC 6.0 statements */
  149.    _setbkcolor(1);
  150.    _settextcolor(7);
  151.    _clearscreen(_GCLEARSCREEN);
  152. }  /* ends clear_text_screen */
  153.  
  154. /******************************************************
  155. *   show_image(...     
  156. *
  157. *   This function displays the image numbers on the 
  158. *   screen as text.  It displays 20 rows  with 18   
  159. *   columns each.
  160. *******************************************************/
  161.  
  162. show_image(image, il, ie)
  163.    int   il, ie;
  164.    short image[ROWS][COLS];
  165. {
  166.    int i, j;
  167.    printf("\n   ");
  168.    for(i=0; i<18; i++)
  169. printf("-%3d", i+ie);
  170.  
  171.    for(i=0; i<20; i++){
  172. printf("\n%2d>", i+il);
  173. for(j=0; j<18; j++)
  174.    printf("-%3d", image[i][j]);
  175.    }
  176.  
  177.    printf("\nPress enter to continue");
  178.    get_integer(&i);
  179.  
  180. }  /* ends show_image  */
  181.  
  182.  
  183. /******************************************************
  184. *   show_menu(..
  185. *   This function displays the CIPS main menu.      
  186. *******************************************************/
  187.  
  188. show_menu()
  189. {
  190.  
  191.   printf("\n\n\nWelcome to CIPS");
  192.   printf("\nThe C Image Processing System"); 
  193.   printf("\nThese are you choices:\n");
  194.   printf("\n\t1.  Display image header");
  195.   printf("\n\t2.  Show image numbers");
  196.   printf("\n\t3.  Print image numbers");
  197.   printf("\n\t4.  Display image");
  198.   printf("\n\t20. Exit system");
  199.   printf("\n\nEnter choice _\b");
  200.  
  201. }    /* ends show_menu */
  202.